List:General Discussion« Previous MessageNext Message »
From:Michael Widenius Date:September 29 1999 11:58am
Subject:Knit-picking questions about mysqldump...
View as plain text  
Hi!

>>>>> "John" == John Millaway <JohnM@stripped> writes:

John> Hi, 1. Is this the preferred way to transfer a mysql db?
John> (pseudo-code) mysqldump host1 >somefile mysql host2 <somefile

This is described in the MySQL manual. The best way is to do:

mysqldump --opt -h host1 database | mysql -h host2 database


John> 2. If so... mysqldump doesn't place "create database" and "use
John> database" at the beginning of the dump script. It also has no
John> flag for the "IF EXISTS" syntax. Will I have to edit the dump
John> script before feeding it into the other database? This is
John> slightly annoying. How can I do a dump/import such that it will
John> always overwrite an existing database of the same name if it
John> exists, or create a new one if it doesn't exists already?

You have to create the database on the other end.  You can however use 
the --force switch to mysql to skip warnings about existing
tables. Another, probably better option is to use the --add-drop-table
option (this is included in the --opt option)

Regards,
Monty
Thread
Knit-picking questions about mysqldump...John Millaway27 Sep
  • Knit-picking questions about mysqldump...Michael Widenius29 Sep