拒绝访问;您需要(至少一个)此操作的SUPER权限

时间:2021-12-14 09:23:51

So I try to import sql file into rds (1G MEM, 1 CPU). The sql file is like 1.4G

所以我尝试将sql文件导入rds(1G MEM,1 CPU)。 sql文件类似于1.4G

mysql -h xxxx.rds.amazonaws.com -u user -ppass --max-allowed-packet=33554432 db < db.sql

mysql -h xxxx.rds.amazonaws.com -u user -ppass --max-allowed-packet = 33554432 db

It got stuck at:

它陷入了困境:

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

The actual sql content is:

实际的sql内容是:

/*!50003 CREATE*/ /*!50017 DEFINER=`another_user`@`1.2.3.4`*/ /*!50003 TRIGGER `change_log_BINS` BEFORE INSERT ON `change_log` FOR EACH ROW
IF (NEW.created_at IS NULL OR NEW.created_at = '00-00-00 00:00:00' OR NEW.created_at = '') THEN
        SET NEW.created_at = NOW();
END IF */;;

another_user is not existed in rds, so I do:

rds中不存在another_user,所以我这样做:

GRANT ALL PRIVILEGES ON db.* TO another_user@'localhost';

Still no luck.

仍然没有运气。

1 个解决方案

#1


32  

Either remove the DEFINER=.. statement from your sqldump file, or replace the user values with CURRENT_USER.

从sqldump文件中删除DEFINER = ..语句,或用CURRENT_USER替换用户值。

The MySQL server provided by RDS does not allow a DEFINER syntax for another user (in my experience).

RDS提供的MySQL服务器不允许其他用户使用DEFINER语法(根据我的经验)。

You can use a sed script to remove them from the file:

您可以使用sed脚本将其从文件中删除:

sed 's/\sDEFINER=`[^`]*`@`[^`]*`//g' -i oldfile.sql

#1


32  

Either remove the DEFINER=.. statement from your sqldump file, or replace the user values with CURRENT_USER.

从sqldump文件中删除DEFINER = ..语句,或用CURRENT_USER替换用户值。

The MySQL server provided by RDS does not allow a DEFINER syntax for another user (in my experience).

RDS提供的MySQL服务器不允许其他用户使用DEFINER语法(根据我的经验)。

You can use a sed script to remove them from the file:

您可以使用sed脚本将其从文件中删除:

sed 's/\sDEFINER=`[^`]*`@`[^`]*`//g' -i oldfile.sql