To back up multiple databases, you can use the following command: mysqldump -uroot -p123456 --databases test1 test2 test3 > /home/test/dump.sql; To restore a backup: source dump.sql -- Enter this command in the MySQL command line to restore Back up the entire database: mysqldump -uroot -123456 -A > all.sql Back up the entire database structure: mysqldump -uroot -p123456 -P3306 -A -d > all_002.sql Back up a single database structure and its data mysqldump -uroot -p123456 -P3306 test > all_003.sql Back up a single database structure and its data mysqldump -uroot -p123456 -P3306 test -d > all_004.sql Backing up a single database mysqldump -uroot -p123456 -P3306 test -t > all_005.sql Generally speaking, the structure and data of the backup database are more commonly used in actual production environments. In the era of big data, data is crucial. Through data analysis, certain user behaviors can be discovered, thereby opening up the market. The backup shell script content is as follows: #!/bin/bash base_dir=/home/test/sql_script DATE=$(date +%Y%m%d) time=$(date "+%Y-%m-%d %H:%M:%S") cd $base_dir mysqldump -uroot -p123456 --databases eluzhupms lms > dump$DATE.sql if [ $? -eq 0 ] then echo "Successfully backed up mysql database, current date:"$time >> /home/test/mysql_dump.log else echo "Backup of mysql database failed: Current date is: "$time>> /home/test/mysql_dump.log fi The above is the details of the commonly used MySQL backup commands and shell backup scripts. For more information about MySQL backup, please pay attention to other related articles on 123WORDPRESS.COM! You may also be interested in:
|
<<: JS implements user registration interface function
>>: How to run Linux commands in the background
Table of contents 1. MySQL replication related co...
In MySQL, we usually use limit to complete the pa...
When we edit a layout, we usually use horizontal ...
This article uses examples to explain the basic k...
This article mainly introduces how to integrate T...
Need to export the fields and properties of the t...
Hyperlink Hyperlinks are the most frequently used ...
This article uses examples to illustrate the simp...
1. Subquery MySQL 4.1 and above support subquerie...
Table of contents react-native project initializa...
1: Install mongodb in docker Step 1: Install mong...
I believe everyone has used JD. There is a very c...
Preface: I recently started to study the construc...
This article shares the specific code for Vue to ...
Preface In our daily development process, sorting...