// MySQL error reference

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
Error message
%s command denied to user '%s'@'%s' for table '%s'

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 SELECT trying 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

  1. Check the account's grants.

    SHOW GRANTS FOR CURRENT_USER();
  2. Grant the missing privilege at the narrowest level that works.

    GRANT INSERT, UPDATE ON shop.orders TO 'app'@'%';

Related errors

More access and privileges errors

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.

// fewer errors, faster fixes

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.