1.備份MySQL數(shù)據(jù)庫的命令
mysqldump -hhostname -uusername -ppassword databasename > backupfile.sql
2.備份MySQL數(shù)據(jù)庫為帶刪除表的格式,能夠讓該備份覆蓋已有數(shù)據(jù)庫而不需要手動刪除原有數(shù)據(jù)庫。
mysqldump -–add-drop-table -uusername -ppassword databasename > backupfile.sql
3.直接將MySQL數(shù)據(jù)庫壓縮備份
mysqldump -hhostname -uusername -ppassword databasename | gzip > backupfile.sql.gz
4.備份MySQL數(shù)據(jù)庫某個(些)表
mysqldump -hhostname -uusername -ppassword databasename specific_table1 specific_table2 > backupfile.sql
5.同時備份多個MySQL數(shù)據(jù)庫
mysqldump -hhostname -uusername -ppassword –databases databasename1 databasename2 databasename3 > multibackupfile.sql
6.僅僅備份數(shù)據(jù)庫結(jié)構(gòu)
mysqldump –no-data –databases databasename1 databasename2 databasename3 > structurebackupfile.sql
7.備份服務(wù)器上所有數(shù)據(jù)庫
mysqldump –all-databases > allbackupfile.sql
8.還原MySQL數(shù)據(jù)庫的命令
mysql -hhostname -uusername -ppassword databasename < backupfile.sql
9.還原壓縮的MySQL數(shù)據(jù)庫
gunzip < backupfile.sql.gz | mysql -uusername -ppassword databasename
10.將數(shù)據(jù)庫轉(zhuǎn)移到新服務(wù)器
mysqldump -uusername -ppassword databasename | mysql –host=*.*.*.* -C databasename