Search code examples
mysqldatabasetriggersproceduredump

Export MySQL database with triggers and procedures?


How to create a MySQL database dump (.sql file) with all its triggers and procedures?


Solution

  • mysqldump will backup by default all the triggers but NOT the stored procedures/functions. There are 2 mysqldump parameters that control this behavior:

    • --routines – FALSE by default
    • --triggers – TRUE by default

    so in mysqldump command , add --routines like :

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

    See the MySQL documentation about mysqldump arguments.