MySQL Error: 1142, SELECT command denied to user

So I went through the error while migrating one of the app to cloud. The full error statement goes like :

MySQL Error: #1142. Response form the database. SELECT command denied to user “username@ip” for table “table1”

From the error statement it looks like that ‘SELECT’ access is missing for the user for that particular table, which is actually true but we have already granted that access to the user then why do we still seeing that error.

From my understanding if you are getting this error then the possible issues and the solutions are:

Solutions for MySQL Error: 1142, SELECT command denied to user:

  1. Double check the Database name: This is the most common scenario as MySQL is case sensitive and using a single upper/lower character can throw this error. Just check that once again.
  2. Double check the user access: Again this is also possible as sometimes we just provide access on a particular table instead of whole database. So make sure you provide access on “database.*”
  3. Check if same table exists in any other database: As the error statement never mentions the database name for which the access is denied, I have ran into this issue because the application was trying to access the table with exactly similar name in some other database on which the access was not granted.

That would be it, let me know if there is any other case where you faced similar issue/error, mention in comments.

Leave a Comment