mysqlのfunctionを作成時のエラー[ERROR 1418 (HY000)]

mysqlのストアドファンクションを作成時に下記のエラーがでた。

/opt/db/mysql/bin/mysql -u root -h 127.0.0.1 -p < CREATE_GET_SITE_ID.sql
ERROR 1418 (HY000) at line 4: 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)

※CREATE_GET_SITE_ID.sqlはストアドファンクションを作成するSQLです。


「log_bin_trust_function_creators」を有効にすることで回避
ストアドファンクションの作成はSUPERまたはCREATE ROUTINE(ALTER ROUTINE)権限を持つ必要があるようだが、 「log_bin_trust_function_creators」を有効にすることで

mysql>SET GLOBAL log_bin_trust_function_creators = 1;


起動時に「 log_bin_trust_function_creators」を有効にするには、my.cnfに記述する。

# vi /etc/my.cnf log_bin_trust_function_creators=1




Mysqlのおすすめ書籍


MySQL徹底入門 第3版 ~5.5新機能対応~
著者:遠藤 俊裕
出版日:2011-08-26

エキスパートのためのMySQL[運用+管理]トラブルシューティングガイド
著者:奥野 幹也
出版日:2010-06-12



Google+