Common commands for Mysql database backup and restoration, mysql Database Backup
Common commands for backing up and restoring Mysql databases are the key to backing up and restoring Mysql databases. There are no commands and nothing can be done, let alone backup and restoration. Only this command is provided to the system, run the command to back up and restore the Mysql database. I. Backup command 1. Backup MySQL database command mysqldump-hhostname-uusername-ppassword databasename> backupfile. sql2. backing up a MySQL database is in the format of a table with deletion, so that the backup can overwrite the existing database without the need to manually delete the original database. Mysqldump -- add-drop-table-uusername-ppassword databasename> backupfile. sql3. directly compress and back up the MySQL database mysqldump-hhostname-uusername-ppassword databasename | gzip> backupfile. SQL .gz 4. Back up a MySQL database (some) table mysqldump-hhostname-uusername-ppassword databasename specific_table1 specific_table2> backupfile. sql5. Back up multiple MySQL databases at the same time: mysqldump-hhostname-uusername-ppassword-databases databasename1 databasename2 databasename3> multibackupfile. sql6. Only back up the database structure mysqldump-no-data-databases databasename1 databasename2 databasename3> structurebackupfile. sql7. Backup all databases on the server mysqldump-all-databases> allbackupfile. SQL 2. Restore command 1. Restore MySQL database command mysql-hhostname-uusername-ppassword databasename <backupfile. sql2. Restore the compressed MySQL database gunzip <backupfile. SQL .gz | mysql-uusername-ppassword databasename3. Transfer the database to the new server mysqldump-uusername-ppassword databasename | mysql-host = *. *. *. *-C databasename
How to back up all databases in mysql using command lines
Keyword: mysql restore or import database command:
Mysql-u root -- password = root
Backup database command:
Mysqldump-u root -- password = root -- database helloworld> helloworld_backup. SQL
Other usage:
1. Export the entire database
Mysqldump-u username-p Database Name> exported file name
Mysqldump-u wcnc-p smgp_rj_wcnc> wcnc. SQL
2. Export a table
Mysqldump-u user name-p Database Name> exported file name
Mysqldump-u wcnc-p smgp_rj_wcnc users> wcnc_users. SQL
3. Export a database structure
Mysqldump-u wcnc-p-d -- add-drop-table smgp_apps_wcnc> d: \ wcnc_db. SQL
-D no data -- add-drop-table adds a drop table before each create statement.
4. Import the database
Common source commands
Go to the mysql Database Console,
For example, mysql-u root-p
Mysql> use Database
Then run the source command. The following parameter is the script file (for example,. SQL used here)
Mysql> source d: \ wcnc_db. SQL
How to back up all databases in mysql using command lines
Keyword: mysql restore or import database command:
Mysql-u root -- password = root
Backup database command:
Mysqldump-u root -- password = root -- database helloworld> helloworld_backup. SQL
Other usage:
1. Export the entire database
Mysqldump-u username-p Database Name> exported file name
Mysqldump-u wcnc-p smgp_rj_wcnc> wcnc. SQL
2. Export a table
Mysqldump-u user name-p Database Name> exported file name
Mysqldump-u wcnc-p smgp_rj_wcnc users> wcnc_users. SQL
3. Export a database structure
Mysqldump-u wcnc-p-d -- add-drop-table smgp_apps_wcnc> d: \ wcnc_db. SQL
-D no data -- add-drop-table adds a drop table before each create statement.
4. Import the database
Common source commands
Go to the mysql Database Console,
For example, mysql-u root-p
Mysql> use Database
Then run the source command. The following parameter is the script file (for example,. SQL used here)
Mysql> source d: \ wcnc_db. SQL