LoginSignup
0

More than 3 years have passed since last update.

MySQLでFunctionを作成するために気を付けること

Posted at

自分でやっていた際に起こったこと。

MySQLにFunctionを作成しようとしたところ、以下のエラーが発生した。

ERROR 1418: 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)

こんなエラーは見たことなかったので調べたところ、意外にも原因がすぐに分かった。
SUPERまたはCREATE ROUTINE(ALTER ROUTINE)権限を持つ必要があるらしいのだが、「log_bin_trust_function_creators」を有効にすることでFunctionを登録できるようになるらしい。
有効にするやり方は以下。

mysql>SET GLOBAL log_bin_trust_function_creators = 1;

ちなみにmy.infに記述をしておくと起動時にlog_bin_trust_function_creatorsが有効になる。

vi /etc/my.cnf log_bin_trust_function_creators=1

あースッキリ。

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
What you can do with signing up
0