Sunday, August 10, 2008

Exporting schema in mysql

You can use the mysqldump command. According to the man page, you can invoke it with:

shell> mysqldump [options] db_name [tables]
shell> mysqldump [options] --databases db_name1 [db_name2 db_name3...]
shell> mysqldump [options] --all-databases

If you don't want data to be dumped, you can use
shell> mysqldump -d -user USERNAME --password=PASSWORD DATABASENAME

It will print the schema to stdout.

To create the database using the exported schema my_schema.sql, you just need to :

mysql --user USERNAME --password=PASSWORD DATABASE_NAME < my_schema.sql

0 Comments:

Post a Comment

<< Home