Thursday, September 07, 2006

Creating a MySQL schema from an existing database

Here's a handy command to create a MySQL db schema from an existing database:
mysqldump --no-data mydb > mydb.sql
The "no-data" option stops db data from being output to the file so that only DROP TABLE and CREATE TABLE lines are output. I found this tip by searching for export MySQL database; I couldn't easily find what I was looking for at the MySQL reference pages.