MySQL database provides a very useful tool mysqldump to back up the database, the following will use the mysqldump command to back up all the databases and specify the database
One, mysqldump backup all database data at once
/usr/local/mysql/bin/mysqldump-u Username-p password--all-databases >/save path/file name. sql
Note: The above command can be entered directly in the console without logging into the database operator interface
Once the above command is executed, you can find your backup SQL file under the corresponding path.
Second, mysqldump one-time backup of the specified multiple database data
/usr/local/mysql/bin/mysqldump-u User name-p password--databases database 1 database 2 ... > Save path/file name. sql
Note: Databases backed up in these two ways will be backed up together with the database creation statement. Therefore, you do not need to create a database before restoring. There are some tools for remotely connecting databases,
Backup functionality is also provided, but backup of the SQL file does not necessarily back up the database creation statement, so when restoring, the database to be saved has already been created, otherwise it cannot be restored.
Third, restore the database using the source command
Using the source command, you need to log in to the database and invoke the command in the database operator interface to restore it, with the following syntax
Source path/file name. sql
The above is the process of using mysqldump for the whole library backup and restore
Use MySQL's own tool mysqldump for full-Library backups and source command recovery databases