Mysql导出函数、存储过程

来源:互联网 发布:python算法 编辑:程序博客网 时间:2024/05/16 15:33
 

下面是导出存储过程的代码

1 # mysqldump -u 数据库用户名 -p -n -t -d -R 数据库名 > 文件名

 

其中,-d 表示--no-create-db, -n表示--no-data, -t表示--no-create-info, -R表示导出function和procedure。所以上述代码表示仅仅导出函数和存储过程,不导出表结构和数据。但是,这样导出的内容里,包含了trigger。再往mysql中导入时就会出问题,错误如下:

ERROR 1235 (42000) at line **: This version of MySQL doesn't yet support ‘multiple triggers with the same action time and event for one table’

所以在导出时需要把trigger关闭。代码为

 

1 # mysqldump -u 数据库用户名 -p -n -t -d -R --triggers=false 数据库名 > 文件名

 

这样导入时,会出现新的问题:

ErrorCode:1418
This function has none of DETERMINISTIC, NOSQL, or READS SQL DATA inits declaration and binary logging is enabled (you *might* want to use the less safe log_bin_trust_function_creators variable)

解决方法是,在/etc/my.cnf中找到[mysqld],在它下面添加这样一行:

 

1 log-bin-trust-function-creators=1