Help Center/ Data Replication Service/ FAQs/ Real-Time Migration/ What Can I Do If the Invoking Permission Problem Occurs After the MySQL Stored Procedure Is Migrated to the Cloud?
Updated on 2024-09-25 GMT+08:00

What Can I Do If the Invoking Permission Problem Occurs After the MySQL Stored Procedure Is Migrated to the Cloud?

After the MySQL stored procedure is migrated to the cloud, an error may occur when the stored procedure or function is invoked due to permission problems.

The method varies with Definer policies. This section uses user1 as an example to describe how to solve this problem in two Definer policies.

Policy 1

On the Destination Database page, enter the database username user1, and select OK for Migrate Definer to User.

Figure 1 Policy 1

In this policy, after the Definers of all stored procedures and methods in the source database are migrated to the destination database, the account is automatically changed to user1, and the value of host is automatically changed to %. If a stored procedure fails to be invoked in the destination database, perform the following operations:

  1. Log in to the RDS for MySQL DB instance of the destination database as the user1.
  2. Grant the execute permission to the account that you want to use to invoke a stored procedure.
  3. Run the following statement to use user1 to grant other accounts the permission to execute stored procedures:

    user indicates other accounts that need to invoke the stored procedure.
    GRANT EXECUTE ON db.* TO user;

  4. To invoke a stored procedure using Java, run the following statement to use user1 to grant other accounts the permission to query the mysql.proc table:

    The following is the authorization statement, in which user indicates the account that needs to invoke the stored procedure:
    GRANT SELECT ON mysql.proc TO 'user'@'%';

Policy 2

On the Destination Database page, enter the database username user1, and select Cancel for Migrate Definer to User.

Figure 2 Policy 2

In this policy, the account and host in the source database remain unchanged after the Definers of all stored procedures and methods are migrated to the destination database. You need to migrate all users in the source database by referring to Migrating Accounts. In this way, the permission system of the source database remains unchanged.

If you do not migrate account permissions or some accounts cannot be migrated, you are advised to use Policy 1.