Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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?

share|improve this question

4 Answers 4

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.

share|improve this answer

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.

share|improve this answer

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.

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

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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