Wednesday, February 2, 2011

Dump just the table structure to a file in MySQL

When you need to back up the table structure from the MySQL database

Syntax:


# mysqldump -d -h localhost -u root -pmypassword databasename > dumpfile.sql

The only option that is different than creating an entire backup is the -d switch, which tells mysqldump not to output the data.

Example:

mysqldump -d -h localhost -u root -p2Uad7as9 database01 > dumpfile.sql