How do I use mysqldump to export only the CREATE TABLE commands?

ぐ巨炮叔叔 提交于 2019-12-02 18:48:48

This uses grep as well, but it seems to work:

mysqldump -d --compact --compatible=mysql323 ${dbname}|egrep -v "(^SET|^/\*\!)"

I'm using:

Ver 10.11 Distrib 5.0.51a, for debian-linux-gnu (x86_64)

Here is the command to dump the schema without the character set and AUTO_INCREMENT.

mysqldump -h localhost -u root -p --no-data  YOUR_DATABASE_HERE |egrep -v "(^SET|^/\*\!)" | sed 's/ AUTO_INCREMENT=[0-9]*\b//'

Here is the command to dump the schema without the character set, AUTO_INCREMENT and the comments

mysqldump -h localhost -u root -p --no-data --compact YOUR_DATABASE_HERE |egrep -v "(^SET|^/\*\!)" | sed 's/ AUTO_INCREMENT=[0-9]*\b//'
mysql> SHOW CREATE TABLE mytablename;
mysqldump --compact --no-set-names --skip-opt --no-data DB | sed "/ SET /d"

Did you try the --skip-comments option mentioned in the manual? Does it help?

http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html#option_mysqldump_comments

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