Ssh fast backup database

  

first enter the folder you need to backup, and then execute the following command

Backup database, ssh command: mysqldump -p database name -u database username> bak.sql ( Can also be the file name you want)

Do not compress backup mysqldump -p database name -u database username> bak.sql

gz compressed backup

mysqldump - p database name -u database username |  Gzip > wuxiaowu.sql.gz

zip compressed backup

mysqldump -p database name -u database username |  Gzip > wuxiaowu.sql.zip



The following of these I have not verified whether it can be used

The following is a summary of the network about MySQL SSH command for database backup and recovery:

Command to back up MySQL database
mysqldump -hhostname -uusername -ppassword databasename > backupfile.sql

Back up MySQL database to back up MySQL database with format of delete table In the format of the delete table, the backup can overwrite the existing database without manually deleting the original database.
mysqldump -–add-drop-table -uusername -ppassword databasename > backupfile.sql

Direct MySQL database compression backup
mysqldump -hhostname -uusername -ppassword databasename |  Gzip > backupfile.sql.gz

Back up some (some) tables of MySQL database
mysqldump -hhostname -uusername -ppassword databasename specific_table1 specific_table2 > backupfile.sql

Back up multiple MySQL databases at the same time
Mysqldump -hhostname -uusername -ppassword –databases databasename1 databasename2 databasename3 > multibackupfile.sql

Backup only database structure
mysqldump –no-data –databases databasename1 databasename2 databasename3 > structurebackupfile.sql

Backup server All databases
mysqldump –all-databases > allbackupfile.sql

Command to restore MySQL database
mysql -hhostname -uusername -ppassword databasename < backupfile.sql

Restore compressed MySQL database< Br>gunzip < backupfile.sql.gz |  Mysql -uusername -ppassword databasename

move the database to the new server
mysqldump -uusername -ppassword databasename |  Mysql –host=*.*.*.* -C databasename Several common database backup instances: 1. Export the entire database mysqldump -u username-p database name> exported file name mysqldump -u root -p dataname > ;dataname.sql will prompt you to enter the password of the root username. After entering the password, the dataname database will be successfully backed up in the current directory. 2. Export a table mysqldump -u username-p database name table name> exported file Name mysqldump -u root -p dataname users> dataname_users.sql3. 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 Add a drop table4 before each create statement. Import the database common source command into the mysql database console, such as mysql -u root -pmysql> use database and then use the source command, the latter parameter is the script file (as used here) .sql)mysql>source d:/wcnc_db.sql

Copyright © Windows knowledge All Rights Reserved