MySQL Forums
Forum List  »  Data Recovery

Restoring database dump to database with different name
Posted by: Michal Koba
Date: November 02, 2009 03:49PM

I have database backup/dump made with mysqldump tool.

mysqldump tool have swith, that allow me to disable adding "create db" statement into dabase backup/dump = --no-create-db. It works fine.

But

backup/dump file contains another statement: USE <database> that point to existing, production database that is currently backed up/dumped.

I need to create automatic process, which allow me, to create test environment for (of course) testing purposes, developing etc.

I had a little hope that I create another script file, that automaticly DROP and CREATE database_test = clear test environment, and when I use mysql command line client tool, to import backup/dump file for restor - I planned to use --database=<database_name> switch to connect to database_test.

so command will looks like this:
mysql --user=<user_name> --password=<password> --host=<hostname> (blablabla) --database=database_test < dump.sql

But

mysqldump tool automatically adds USE <database> to dump file, that overrides --database=database_test parameter.

How can I disable adding USE <database> statement to dump file by mysqldump tool (of course - I can develop simple application that disable any line containing USE word - but maby there is simple solution for my problem)

Options: ReplyQuote


Subject
Views
Written By
Posted
Restoring database dump to database with different name
14086
November 02, 2009 03:49PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.