Issue description
One of the following errors occurs when creating a stored procedure, function, trigger, event, or view.
The error occurs during the import of SQL script files (usually from an on-premises database) into RDS.
One of the following errors occurs when downloading logical backup files from an RDS instance running MySQL 5.6 and importing them into the RDS instance or an on-premises database. The error code may be 1227 or 1725.
The error occurs when executing a MySQL statement to modify parameters.
[Err] 1227 - Access denied; you need (at least one of) the SUPER privilege(s) for this operation -- This error commonly occurs on an RDS instance that runs MySQL 5.6
ERROR 1725 (HY000) at line 1936: OPERATION need to be executed set by ADMIN -- This error commonly occurs on an RDS instance that runs MySQL 5.5
ERROR 1227 (42000) at line 2984: Access denied; you need (at least one of) the SUPER privilege(s) for this operation
Causes
SQL statements that require SUPER privileges to execute, such as
DEFINERandGTID_PURGED, are present when importing data into an RDS MySQL instance. RDS MySQL does not grant SUPER privileges, necessitating the removal of these statements.The on-premises MySQL instance lacks a global transaction identifier (GTID).
Database accounts lack the necessary permissions to modify specific parameters by executing MySQL statements, such as SET GLOBAL event_scheduler = 1.
Solutions
Import data into RDS using a privileged account. Contact your administrator if you lack the necessary permissions.
Remove DEFINER-related statements from the SQL script before import.
Locate and remove DEFINER statements similar to the example provided from your SQL file.
DEFINER=`root`@`%`Use the following command in Linux to eliminate the statements.
sed -ie 's/DEFINER[ ]*=[ ]*[^ ]*/ / ' your.sql
Remove GTID_PURGED-related statements from the SQL script before import.
NoteWhen exporting data from an on-premises database, use the parameter
--set-gtid-purged=offafter themysqldumpcommand to prevent the inclusion of GTID_PURGED clauses.Locate and remove GTID_PURGED statements similar to the example provided from your SQL file.
SET @@GLOBAL.GTID_PURGED='d0502171-3e23-11e4-9d65-d89d672af420:1-373, d5deee4e-3e23-11e4-9d65-d89d672a9530:1-616234';Use the following command in Linux to eliminate the statements.
awk '{ if (index($0,"GTID_PURGED")) { getline; while (length($0) > 0) { getline; } } else { print $0 } }' your.sql | grep -iv 'set @@' > your_revised.sql
Applies to
ApsaraDB RDS for MySQL