angryteacup
angryteacup

Reputation: 1

Does a MySQL backup save custom functions, events, and queries?

I successfully did a backup of my database, dropped the DB in workbench and created a new one, and attempted to restore it. First, it didn’t restore until I ran the creation of a custom function first (which is something I use in multiple views), and when I did restore it, the event I created wasn’t present.

FUNCTION library.daysout does not exist

I can understand why a query I had open would not be restored (although if you can tell me how to do that, please do,) but how can I make sure my custom function and event restore (especially since the DB doesn’t restore till I run the creation of the function before)?

Upvotes: 0

Views: 512

Answers (1)

Bill Karwin
Bill Karwin

Reputation: 562250

A default database dump or export does not include stored procedures or stored functions by default.

MySQL Workbench has a checkbox to include stored procedures and functions in an export. You have to check this, and it's not checked by default.

enter image description here

This option is shown in the screenshots in the manual here: https://dev.mysql.com/doc/workbench/en/wb-admin-export-import-management.html Although it isn't described clearly in the text.

Likewise if you use the command-line mysqldump tool, you must use the --routines option to include stored procedure and stored function definitions in the export. This option is documented here: https://dev.mysql.com/doc/refman/8.0/en/mysqldump.html#option_mysqldump_routines

Upvotes: 1

Related Questions