Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to backup stored procedures in MySQL

Tags:

I use mysqldump with MySQL 5.0 and I back it up every day, but do not understand the method that only stored procedure backs up.

How can I back it up?

like image 344
freddiefujiwara Avatar asked May 19 '09 06:05

freddiefujiwara


People also ask

How do I backup a MySQL procedure?

From the doc: -R, --routines Dump stored routines (functions and procedures). -r, --result-file=name Direct output to a given file. This option should be used in MSDOS, because it prevents new line '\n' from being converted to '\r\n' (carriage return + line feed).

Does Mysqldump include stored procedures?

mysqldump will backup by default all the triggers but NOT the stored procedures/functions.

How do you dump a function in MySQL?

We simply need to add the parameter --routines to the mysqldump command in order to include the functions and stored procedures to our dump file. We now have our dump file containing the functions and stored procedures. This entry was posted on 01 Mar 2011, 20:39 and is filed under MySQL.


1 Answers

I'm not sure whether you're asking to back up stored procedures as well as everything else, or just the stored procedures on their own...

Stored procedured in dump with everything else:

mysqldump -R <dbname> #or mysqldump --routines <dbname> 

Just the stored procedures:

mysqldump -n -t -d -R <dbname> #or mysqldump --no-create-db --no-create-info --no-data --routines <dbname> 

Does that help?

like image 160
Stobor Avatar answered Oct 29 '22 02:10

Stobor