Monday, June 18, 2012

MySQL : Use mysqldump to get the schema only


Dumping the database structure for all tables with no data


Add the -d flag to signify that no data should be included in the output like so, where "mydatabase" is the name of the database to dump, and "someuser" is the login name used to connect to the database
mysqldump -d -u someuser -p mydatabase

Dumping the database structure for one table with no data

mysqldump -d -u someuser -p mydatabase products

Dumping the database structure for several table with no data

mysqldump -d -u someuser -p mydatabase products categories users

Dumping the structure to a file

mysqldump -d -u someuser -p mydatabase > mydatabase.sql

Restore the structure file to mysql

mysql -u someuser -p anotherdatabase < mydatabase.sql

0 comments:

Post a Comment