Help us understand the problem. What is going on with this article?

RDSのmysqlでトリガーが作れない I couldn't create trigger in mysql RDS

More than 1 year has passed since last update.

RDSでmysqldumpで取得したファイルをインポートしようとしたら、以下のエラーが出ました。
その中には、トリガーも含まれていたので、以下のような記述もありました。
I got dump file by using mysqldump, and tried to import it into mysql on RDS.
But, this error occurred.

/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `product_log` AFTER INSERT ON `product`
FOR EACH ROW
    INSERT INTO ........

RDSではsuper権限は持てないので、以下を設定しましょう、というのは、公式ドキュメントにも載っているので、設定してみた。
In RDS, super privilege is unavailable. We need to change a parameter group.

https://aws.amazon.com/jp/premiumsupport/knowledge-center/error-1227-mysqldump/

ERROR 1419 (HY000) at line 3155: You do not have the SUPER privilege and binary logging is enabled (you *might* want to use the less safe log_bin_trust_function_creators variable)

この状況を緩和するには、RDS カスタムパラメーターグループの log_bin_trust_function_creators システム変数に 1 を設定します。
To relax this condition, set the global log_bin_trust_function_creators system variables to 1 through the RDS custom parameter group.

しかし、状況は解決せず、筆者の環境では、それでも以下のエラーが出た。
But, the problem wasn't solved. the error below occurred in my case.

ERROR 1227 (42000) Access denied; you need (at least one of) the SUPER privilege(s) for this operation

トリガーなどの作成時にDEFINER属性が含まれていると、作成時にDEFINER属性で指定したユーザーを使おうとしてしまうので、上記のエラーが出てしまう。そのため、
If dumpfile includes DEFINER attribute, mysql tries to create trigger with the specified user in DEFINER attribute.
To solve this is that remove the DEFINER attribute.

DEFINER=`root`@`localhost`

この部分を削除してあげれば、問題なく作成することができます。
My problem was solved by removal of this attribute!

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした