Error is reported for RDS MySQL

Problem description

  • The following error occurs when you create a stored procedure, function, trigger, event, or view:
  • When you export an SQL statement from a local database, the following error occurs when you apply this SQL statement to apsaradb for RDS:
  • When you download a logical backup from an RDS MySQL 5.6 instance to an apsaradb for RDS instance or an on-premises database, the following errors occur. The error codes are 1227 and 1725.

    1. [Err] 1227 - Access denied; you need (at least one of) the SUPER privilege(s) for this operation-common in RDS MySQL 5.6
    2. ERROR 1725 (HY000) at line 1936: OPERATION need to be executed set by ADMIN-common in RDS MySQL 5.5
    3. ERROR 1227 (42000) at line 2984: Access denied; you need (at least one of) the SUPER privilege(s) for this operation

    Causes

  • When you import data to the RDS for MySQL instance, the SQL statement contains one or more SQL statements that require the Super permission to run. The RDS for MySQL instance does not provide the Super permission to run such SQL statements. Therefore, you must delete these SQL statements.

  • GTID is not enabled for the local MySQL instance.

Solutions

1. Delete the DEFINER statement
  • Check the SQL file and delete SQL statements such as the following.
    1. DEFINER=`root`@`%`
  • In Linux, you can try to delete using the following command.
    1. sed -ie 's/DEFINER[ ]*=[ ]*[^ ]*/ / 'your.sql
2. Delete the GTID_PURGED statement
  • Check the SQL file and delete SQL statements such as the following
    1. SET @@GLOBAL.GTID_PURGED='d0502171-3e23-11e4-9d65-d89d672af420:1-373, d5deee4e-3e23-11e4-9d65-d89d672a9530:1-616234';
  • In Linux, you can try to delete using a command similar to the following
    1. awk '{ if (index($0,"GTID_PURGED")) { getline; while (length($0) > 0) { getline; } } else { print $0 } }' your.sql | grep -iv 'set @@' > your_revised.sql