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