0

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?

Niro
  • 1,401
  • 4
  • 20
  • 36

4 Answers4

5

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.

joschi
  • 21,387
  • 3
  • 47
  • 50
3

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

Maxwell
  • 5,076
  • 1
  • 26
  • 31
1

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.

Stenstad
  • 21
  • 2
1
mysqldump -d database | ssh otherhost "mysql -Ddatabase"