存储过程和函数无法迁移的解决方法

来源:互联网 发布:hive sql注释写法 编辑:程序博客网 时间:2024/05/04 13:18

http://blog.g12e.org/jarod/blog/article/90901.html

 

储过程和函数无法迁移的解决方法

作者:我自横刀向天笑

存储过程和函数无法迁移的解决方法
MySQL自5.0之後終於支援SP( Store Procedures ),
SP的好處在於速度快、提高資料安全性、降低程式碼重複率等...
但是在實作SP的時候遇到了些問題,
不管CREATE FUNTION 或是CREATE PROCEDURE都會出現以下的錯誤,
ERROR 1418 (HY000): This function has none of DETERMINISTIC, NO SQL,
or READS SQL DATA in its declaration and binary logging is enabled
(you *might* want to use the less safe log_bin_trust_function_creators
variable
參考MySQL on-line help後,Section 17.4, “Binary Logging of Stored Routines and Triggers”.說明
原來是有一段設定需要調校
log_bin_trust_function_creators這項參數預設是0,但是這樣會影響SP的設置,因此必須調為1
調整的方式可以有三種(雖然斯斯已經有四種了)
1. mysql> SET GLOBAL log_bin_trust_function_creators = 1;
2. 系統啟動時,加上--log-bin-trust-function-creators 參數為1
3. 直接在my.ini的[mysqld]區段加上log-bin-trust-function-creators=1
當然我想大多數人會用第三種方法,

原创粉丝点击