views:

25

answers:

3

So the command I normally use to get a database sent to another server is: mysqldump -u user -p --add-drop-tables database *file*

But I always have to go into the file and add a line at the top: use database;

So that I use the file to import to a different server. Is there a flag in mysqldump to automatically add the use database?

A: 

Hi,

Did you try adding: --databases THE_DB_NAME

redhatlab
A: 

Hi The flag is --databases

mysqldump -u user -p --add-drop-tables --databases database > file

So if you have more than one schema names you need to set which databases with the --databases flag. Then it inserts wich one is necessary to be used.

Alex Mandl
A: 

Alternatively you can write a small bash script or batch file (depending on OS) with the lines you want to add to the file.

Sundar