1142 🐬 MySQL

MySQL ERROR 1142 (42000): SELECT command denied to user 'x'@'host' for table 'y'

The account lacks the privilege for that statement on that table.

Seen on: MySQL

Meaning

Users often have privileges on one database but not another, or lack ALTER/CREATE/TRIGGER needed by migrations.

Common causes

  • Missing GRANT for the statement type
  • Privileges on a different database
  • Views/triggers needing extra privileges

⚡ Quick fix

  1. GRANT the needed privileges
  2. Use separate migration and app users deliberately
  3. Check SHOW GRANTS

Detailed fix by platform

MySQL

  1. GRANT SELECT, INSERT, UPDATE, DELETE ON appdb.* TO 'app'@'%';

How to diagnose

  1. Privilege — Which command?
  2. Grants — SHOW GRANTS FOR user

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.