Mysql导出存储过程

在部署某学院的网站时,发现一个错误:

1 FUNCTION config_get does not exist.

找到代码一看,是conn.prepareCall("{call config_get(?,?,?)}");这一句出了错。上网查了查,这是在调用存储过程, 那么config_get就是存储过程名。到数据库里用show procedure status;看了看,一个存储过程也没有。也就是导数据库时没有导存储过程。

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

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
原文地址:https://www.cnblogs.com/yuepeng/p/1832775.html