默认情况下,mysqldump备份整个数据库。我需要在MySQL中备份单个表。可能吗?如何还原?
mysqldump
倾倒
mysqldump db_name table_name > table_name.sql
从远程数据库转储
mysqldump -u <db_username> -h <db_host> -p db_name table_name > table_name.sql
进一步参考:
http://www.abbeyworkshop.com/howto/lamp/MySQL_Export_Backup/index.html
恢复
mysql -u <user_name> -p db_name mysql> source <full_path>/table_name.sql
或一行
mysql -u username -p db_name < /path/to/table_name.sql
图片来源:John McGrath
mysqldump db_name table_name | gzip > table_name.sql.gz
gunzip < table_name.sql.gz | mysql -u username -p db_name