Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Importing mysql procedures generated from mysqldump --routines

I use the mysqldump tool to make copies of my database. The problem is, when I use the --routines parameter to output my stored procedures along with my data, the generated output causes an error when I try to import it.

It goes something like this:

% mysqldump --routines MyDB | mysql MyDB2

(where MyDB2 already exists but is empty)

The error I get is the following:

ERROR 1064 (42000) at line 307: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 23

Everything works correctly if I omit the --routines.

Has anyone else encountered this?

like image 202
Clayton Avatar asked Feb 02 '09 19:02

Clayton


People also ask

Does Mysqldump include stored procedures?

Importing your stored procedures, functions and triggers By default, mysqldump imports views and triggers. However it does not import procedures, functions and events. To import procedures and functions, the --routines option should be specified, and to import events, the --events option should be specified.

Are MySQL stored procedures compiled?

MySQL stored procedures are pre-compiled SQL statements stored in a database. They are subroutines containing a name, a parameter list, and SQL statements.


1 Answers

I was able to get this to work by splitting it into two calls:

% mysqldump MyDB | mysql MyDB2
% mysqldump --routines --no-create-info --no-data --no-create-db --skip-opt MyDB | mysql MyDB2
like image 64
Clayton Avatar answered Sep 22 '22 02:09

Clayton