0

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)?

1
  • Please provide enough code so others can better understand or reproduce the problem. Commented Aug 7, 2022 at 6:10

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks! I've been using command line, didn't see the checkbox in workbench. Are events similarly included if we check dump stored procedures and functions?
Check the documentation links I gave. The answers are there!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.