mysql 数据库备份与还原命令
1>导出某个数据库表结构
(其他说明:-u 后面的root为用户名,-p后面的password为用户密码,dbname数据库名称)mysqldump –uroot –ppassword –d dbname > /home/test/dbfiles/dbtables.sql
2>导出某个数据库某张表或多张表表结构
mysqldump –uroot –ppassword –d dbname tablename1>/home/test/dbfiles/dbtable.sql
(多张表表名之间以空格隔开)
mysqldump –uroot –ppassword –d dbname tablename1 tablename2>/home/test/dbfiles/dbtable.sql
3>导出某个数据库数据以及表结构
mysqldump –uroot –ppassword dbname>/home/test/dbfiles/db.sql
4>导出某个数据库中某个表或某几张表数据以及表结构
mysql –uroot –ppassword dbname tablename1>/home/test/dbfiles/dbtable1.sql
(多张表表名之间以空格隔开)
mysql –uroot –ppassword dbname tablename1 tablename2>/home/test/dbfiles/dbtables.sql
5>还原备份
mysql -u root –p password dbname < /home/test/dbfiles/db.sql
或者登录MySQL然后
Mysql>/home/test/dbfiles/db.sql;
【注意】还原备份命令是mysql不是mysqldump
https://www.leftso.com/article/6.html