I have a mysql db with many tables. I'm starting a new farm which should contain empty versions of the same database tables.

How can I efficiently create empty database based on existing one?

link|improve this question

80% accept rate
feedback

4 Answers

up vote 3 down vote accepted

You need to dump the source database using the mysqldump -d option and then do a restore to the destination servers. Hope this helps.

link|improve this answer
feedback

Use mysqldump --no-data to dump the database schema but not the data and then restore that dump on your new database server. If you are using triggers or stored procedures you should include the respective parameters in your mysqldump call.

See 4.5.4. mysqldump — A Database Backup Program for details.

link|improve this answer
feedback

After you've made the dump, you can execute the SQL statements in your dump in the mysql client:

mysql> . dbdump.sql

If this is the same server, be sure to edit the dumpfile first to change the database name.

link|improve this answer
feedback
mysqldump -d database | ssh otherhost "mysql -Ddatabase"
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.