How to dump mysql database?

前提是你 提交于 2019-11-30 05:12:31

问题


I want to dump mysql database only the tables which have data, Can u please give me your suggestion. this is more helpful

Thanks & Regards, Vara Kumar.PJD


回答1:


You can use the --ignore-table option, but you have to find out which tables are empty first as this is not directly possible with mysqldump. So you could do

mysqldump -u username -p database --ignore-table=database.table1 --ignore-table=database.table2 > database.sql



回答2:


mysqldump <database options> table1 table2 table3 ...



回答3:


Use mysqldump (documentation located here). If you do not specify tables it assumes all tables. You can also explicitly choose tables to copy or to ignore. You can tell it to create drop statements before your create statements. If you have mysql 5.1.2 then you can tell it to copy routines.




回答4:


When you are dumping all database. Obviously it is having large data. So you can prefer below for better:

Creating Backup:

mysqldump -u [user] -p[password]--single-transaction --quick --all-databases | gzip > alldb.sql.gz

If error

-- Warning: Skipping the data of table mysql.event. Specify the --events option explicitly.

Use:

mysqldump -u [user] -p --events --single-transaction --quick --all-databases | gzip > alldb.sql.gz

Restoring Backup:

gunzip < alldb.sql.gz | mysql -u [user] -p[password]

Hope it will help :)



来源:https://stackoverflow.com/questions/3725077/how-to-dump-mysql-database

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!