开发者

Mysqldump question

I am trying to dump a large database usin开发者_StackOverflow中文版g mysqldump command. I would like to avoid 'use database' command in the generated sql file. This is because I want to create the same database with a different name. Since the sql file size is large I am unable to open the sql file and edit it.

I tried --no-create-db but still I am getting use command in the dump file

Please help.


Maybe you used something like this:

mysqldump -u -p <other options> --database your_database > file.sql

I discovered that when you use --database, the script is generated with that 'use your_database' line. So, don't use that option and the line is gone:

mysql -u -p <other options> your_database > file.sql


You should maybe post this on serverfault, but if you are on a linux box, you could consider sed (or perl/python scripts) to replace the name of the database, or remove the "use " line.


The way to do this is to run mysqldump once for each database. They way I did it is mysqldump -u user -p --tables databasename. This dumps all the tables for a database and removes the USE database statement.


--no-create-db is your friend:

http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html#option_mysqldump_no-create-db

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜