# mysqldump: how to include routines
By default, mysqldump does not include the routines when dumping a database. If you want to include the routines, you have to pass the
-R parameter when running
Below are two examples showing how to use both forms of the parameter.
# Using the --routines flag
mysqldump my_database --routines > my_backup.sql
# Using the -R flag
mysqldump my_database -R > my_backup.sql
The resulting dump after running one of the above commands will contain the routines as well.
--all-databases option before & after MySQL 8.0
Before MySQL 8.0, if you executed mysqldump using the
--all-databases option, the routines were also included. From MySQL 8.0 this behaviour has changed. If you are running mysqldump with the flag
--all-databases, you must explicitly include the flag
--routines if you want to have the same behavior as before MySQL 8.0