MySQL error 1142: Command denied to user for table
The account lacks the table privilege the statement needs, such as SELECT, INSERT, UPDATE, DELETE, DROP or ALTER on that table.
- Error number
1142- Name
ER_TABLEACCESS_DENIED_ERROR- SQLSTATE
42000- Category
- Access and privileges
What it means
MySQL checks privileges for each table a statement touches. The message names the command (SELECT, INSERT, ...), the account and the table that failed. Privileges can come from global, database, table or column grants; none of them allowed this command here.
Common causes
- An application account granted only
SELECTtrying to write. - Grants given on one database while the statement touches a table in another.
- A view or trigger touching tables the account (or the view's definer) can't access.
- Grants given to a different host part of the account.
How to fix it
-
Check the account's grants.
SHOW GRANTS FOR CURRENT_USER();
-
Grant the missing privilege at the narrowest level that works.
GRANT INSERT, UPDATE ON shop.orders TO 'app'@'%';
Related errors
1143Command denied to user for column1044Access denied for user to database1227Access denied; you need a privilege229SQL Server: Permission denied on object42501PostgreSQL: permission deniedORA-01031Oracle: insufficient privileges
More access and privileges errors
1045Access denied for user1130Host is not allowed to connect1698Access denied for user (no password)1396Operation CREATE USER failed1419SUPER privilege needed with binary logging1449Definer user does not exist
The code and message text are from the MySQL 8.4 Error Message Reference. Browse the full MySQL error list or search every database error.
Work on MySQL in SQLly
A native SQL client for macOS, Windows and Linux with schema-aware IntelliSense, guardrails for risky statements and clear error messages, for MySQL and the other databases you use.