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
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.
Use Wireshark to capture packets and obtain actual requests that are sent by the on-premises machine.
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.
Reproduce the error. Then, stop capturing packets.
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.
Right-click the packet that causes the error and choose Follow TCP Stream > TCP Stream.
Check the SQL statement that is sent. If the database name is incorrect, modify the database name.
Summary
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.
Capture packets and analyze the SQL statement that is executed.
Applicable scope
ApsaraDB RDS for MySQL