Exporting a Database Schema in MySQL

File this under “Useful things to remember”.

The following bit of command line magic will export the schema of your database.

mysqldump –no-data –tables -u YOUR_USER_NAME -p DATABASE_YOU_WANT_SCRIPTED >> FILENAME.sql


An example looks like this:


mysqldump –no-data –tables -u larry -p contacts >> contacts.sql

If you want the data as well, omit the “–no-data” portion.