Dumping MySQL Stored Procedures, Functions and Triggers

When you run mysqldump , by default it will not export your procedures or function , if you want to include these info , you need to add –routines option in your mysqldump command.

mysqldump <other mysqldump options> —routines > outputfile.sql

Let’s assume we want to backup ONLY the stored procedures and triggers and not the mysql tables and data (this can be useful to import these in another db/server that has already the data but not the stored procedures and/or triggers), then we should run something like:

mysqldump --routines --no-create-info --no-data --no-create-db --skip-opt <database> > outputfile.sql
and this will save only the procedures/functions/triggers of the <database>. If you need to import them to another db/server you will have to run something like:

mysql <database> < outputfile.sql


Leave a Reply

Your email address will not be published. Required fields are marked *