Thursday, November 20, 2008

mysqldump with stored procedures, triggers and functions.

Dumping data with mysqldump could be tricky with all the available options. If you are looking to backup all the data and triggers, here's the set of options you need.


backup complete database


mysqldump -u myusername --password=mypassword --databases mydatabase --skip-opt --routines > dump.sql


if you only want to backup the triggers and functions etc then you could use


mysqldump -u myusername --password=mypassword --database mydatabase --skip-opt --routines --no-create-info --no-data --no-create-db > no-data-dump.sql

Use --opt if you want to include the auto_increment as well in the create command.

No comments: