備份
備份數(shù)據(jù)庫
// 備份數(shù)據(jù)庫下的所有表,不包含創(chuàng)建數(shù)據(jù)庫破加,導(dǎo)入前需要創(chuàng)建數(shù)據(jù)庫
$> mysqldump -u root -h host -p dbname1> backdb.sql
// 備份數(shù)據(jù)庫,包含創(chuàng)建數(shù)據(jù)庫
$> mysqldump -u root -h localhost -p --databases test > backdb.sql
// 備份全部數(shù)據(jù)庫
$> mysqldump -u root -h host -p --all-databases > backdb.sql
- 備份表
$> mysqldump -u root -h host -p dbname tbname1, tbname2 > backdb.sql
還原數(shù)據(jù)庫
// 表導(dǎo)入
$> mysql -u root -p dbname < backup.sql
// 整個數(shù)據(jù)庫導(dǎo)入
$> mysql -u root -p < backup.sql