tags:

views:

93

answers:

3

I am trying to dump a large database using 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.

+1  A: 

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.

Aif
A: 

--no-create-db is your friend:

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

pulegium
I tried --no-create-db but still I am getting use comand in the dump file.
right, then just use sed to replace:sed -i 's/use old_db_name/use new_db_name/' db_dump.sql
pulegium
A: 

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.

spig