All Products
Search
Document Center

ApsaraDB RDS:What do I do if the "SELECT command denied to user 'username'@'ip' for table 'user'" error message is displayed when I use an ApsaraDB RDS for MySQL instance?

Last Updated:Aug 24, 2023

Problem description

When I use a program to execute an SQL statement to query a database on my ApsaraDB RDS for MySQL instance, the following error message is displayed:

SELECT command denied to user 'username'@'ip' for table 'user' 

Cause

The name of the database is incorrect, and the user table does not exist in the database.

Solution

  1. Check whether the RDS instance is running as expected. You can connect to the RDS instance by using a MySQL client and query the required table. If you can query the table, your RDS instance is running as expected.

  2. Use Wireshark to capture packets and obtain actual requests that are sent by the on-premises machine.

    1. On the Wireshark page, choose Capture > Options. On the Input tab, select the internal network interface controller (NIC) that is used to connect to the RDS instance. On the Output tab, enter the name of the output file and click Start.

    2. Reproduce the error. Then, stop capturing packets.

  3. Open the captured packet file that is generated, enter mysql in the filter to identify packets sent over the MySQL protocol, and then find the packet that causes the error.

  4. Right-click the packet that causes the error and choose Follow TCP Stream > TCP Stream. TCP流

  5. Check the SQL statement that is sent. If the database name is incorrect, modify the database name.

Summary

  1. Check the program that you used to execute the SQL statement and confirm that the SQL statement sent to the server conforms to SQL syntax.

  2. Capture packets and analyze the SQL statement that is executed.

Applicable scope

  • ApsaraDB RDS for MySQL