mysqldump from a query

这一生的挚爱 提交于 2019-12-03 19:53:40

问题


How can I make a mysql dump for table from a query?

I need something like this..

mysqldump -uroot -pxxxx mydb "select * from table where name='1';" >  /tmp/a

Thanks.


回答1:


mysqldump has a --where parameter: Manual

Dump only rows selected by the given WHERE condition. Quotes around the condition are mandatory if it contains spaces or other characters that are special to your command interpreter.

Examples:

--where="user='jimf'"

-w"userid>1"

-w"userid<1"

I don't know what they use, but phpMyAdmin can do this too, Just make the query, select all rows and choose the "export" button to the bottom.




回答2:


Another option is to insert your query results into a tmp table, then dump that tmp table.



来源:https://stackoverflow.com/questions/2431912/mysqldump-from-a-query

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