mysql trigger 设置错误ERROR1419

mysql 触发器设置

background: mysql触发器可以在对数据库数据进行变更(插入,修改,删除)之前或之后触发操作。

在设置mysql触发器时提示:

ERROR 1419 (HY000): 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)

提示没有super权限,有几种方法可以解决这个问题,现记录目前使用的方法:对需要设置触发器的用户提供super权限
使用root用户登陆数据库,运行:
GRANT ALL PRIVILEGES ON *.* TO username@'%';   ## username is the username you would like to grant super privilege.
FLUSH PRIVILEGES;

如果想重新创建一个用户,可以使用:

CREATE USER canal IDENTIFIED BY 'canal';  
GRANT ALL PRIVILEGES ON *.* TO 'canal'@'%';  -- GRANT ALL PRIVILEGES ON 数据库名.表名 TO 'canal'@'%' ;  
FLUSH PRIVILEGES;

然后使用已经授权的用户登陆就可以进行触发器设置了。

还有其他方法如将所有用户提权,以及关闭备份和binlog的方法,由于未曾使用,不再赘述。 

原文地址:https://www.cnblogs.com/buxizhizhoum/p/7599907.html