1143
MySQLERRORNotableSecurityHIGH confidence

SELECT command denied to user for column in table

Production Risk

Low — access is denied; data is protected.

What this means

ER_COLUMNACCESS_DENIED_ERROR (1143, SQLSTATE 42000) is raised when a user attempts to access a specific column for which they lack column-level privilege.

Why it happens
  1. 1Column-level privilege restriction prevents access to sensitive fields (e.g., salary, ssn)
  2. 2User has table-level SELECT but a specific column has been restricted via column grants
How to reproduce
trigger — this will error
trigger — this will error
-- As user with column-level restriction:
SELECT salary FROM employees;

expected output

ERROR 1143 (42000): SELECT command denied to user 'user'@'host' for column 'salary' in table 'employees'

Fix

Grant column-level SELECT privilege

WHEN User legitimately needs the column.

Grant column-level SELECT privilege
GRANT SELECT (salary) ON mydb.employees TO 'user'@'host';

Why this works

Column-level GRANT allows SELECT on specific columns while restricting others.

What not to do

Grant table-level SELECT to bypass column restrictions

Column-level restrictions are intentional security controls; granting broader access undermines them.

Sources
Official documentation ↗

MySQL 8.0 — 1143 ER_COLUMNACCESS_DENIED_ERROR

Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev

← All MySQL errors