Lab-verifiedReproduced and fixed on MySQL 8.4.13 · 2026-11-30 · container image mysql:8.4
ERROR 1143 appears when a user was granted privileges on specific columns (GRANT SELECT (id, name, dept) ON hr.emp ...) and a statement uses another column. The message names the command and the column, for example SELECT command denied ... for column 'salary'.
We reproduced three cases on MySQL 8.4 with lab_a, who has SELECT (id, name, dept) and UPDATE (dept) on hr.emp. The salary column is not granted.
01Selecting a column that is not granted
SELECT id, name, salary FROM hr.emp failed on salary, even though id and name are granted. One ungranted column is enough.
Setup
CREATE DATABASE hr;
CREATE TABLE hr.emp (id INT PRIMARY KEY, name VARCHAR(20), dept VARCHAR(10), salary INT);
INSERT INTO hr.emp VALUES (1, 'kim', 'sales', 4200), (2, 'lee', 'dev', 5100);
GRANT SELECT (id, name, dept), UPDATE (dept) ON hr.emp TO lab_a;Query OK, 1 row affected (0.01 sec)
Query OK, 0 rows affected (0.01 sec)
Query OK, 2 rows affected (0.01 sec)
Records: 2 Duplicates: 0 Warnings: 0
Query OK, 0 rows affected (0.00 sec)SELECT id, name, salary FROM hr.emp;ERROR 1143 (42000): SELECT command denied to user 'lab_a'@'127.0.0.1' for column 'salary' in table 'emp'SELECT column_name, privilege_type FROM information_schema.column_privileges
WHERE table_schema = 'hr' AND table_name = 'emp' ORDER BY column_name, privilege_type;+-------------+----------------+
| column_name | privilege_type |
+-------------+----------------+
| dept | SELECT |
| dept | UPDATE |
| id | SELECT |
| name | SELECT |
+-------------+----------------+
4 rows in set (0.00 sec)information_schema.column_privileges lists SELECT only for dept, id, name — no salary.
SELECT id, name, dept FROM hr.emp;+----+------+-------+
| id | name | dept |
+----+------+-------+
| 1 | kim | sales |
| 2 | lee | dev |
+----+------+-------+
2 rows in set (0.00 sec)Selecting only the granted columns (id, name, dept) returned both rows.
SELECT id, name, dept FROM hr.emp;+----+------+-------+
| id | name | dept |
+----+------+-------+
| 1 | kim | sales |
| 2 | lee | dev |
+----+------+-------+
2 rows in set (0.00 sec)02Using an ungranted column in WHERE of an UPDATE
lab_a may update dept, but UPDATE hr.emp SET dept = 'hq' WHERE salary > 5000 still failed. Reading salary in WHERE needs SELECT on it, so the message says SELECT command denied.
Setup
CREATE DATABASE hr;
CREATE TABLE hr.emp (id INT PRIMARY KEY, name VARCHAR(20), dept VARCHAR(10), salary INT);
INSERT INTO hr.emp VALUES (1, 'kim', 'sales', 4200), (2, 'lee', 'dev', 5100);
GRANT SELECT (id, name, dept), UPDATE (dept) ON hr.emp TO lab_a;Query OK, 1 row affected (0.01 sec)
Query OK, 0 rows affected (0.01 sec)
Query OK, 2 rows affected (0.01 sec)
Records: 2 Duplicates: 0 Warnings: 0
Query OK, 0 rows affected (0.00 sec)UPDATE hr.emp SET dept = 'hq' WHERE salary > 5000;ERROR 1143 (42000): SELECT command denied to user 'lab_a'@'127.0.0.1' for column 'salary' in table 'emp'SELECT column_name, privilege_type FROM information_schema.column_privileges
WHERE table_schema = 'hr' AND table_name = 'emp' ORDER BY column_name, privilege_type;+-------------+----------------+
| column_name | privilege_type |
+-------------+----------------+
| dept | SELECT |
| dept | UPDATE |
| id | SELECT |
| name | SELECT |
+-------------+----------------+
4 rows in set (0.00 sec)dept has UPDATE, but salary has no privilege at all.
GRANT SELECT (salary) ON hr.emp TO lab_a;
SHOW GRANTS FOR lab_a;Query OK, 0 rows affected (0.01 sec)
+---------------------------------------------------------------------------------------------+
| Grants for lab_a@% |
+---------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO `lab_a`@`%` |
| GRANT ALL PRIVILEGES ON `lab_a`.* TO `lab_a`@`%` |
| GRANT SELECT (`dept`, `id`, `name`, `salary`), UPDATE (`dept`) ON `hr`.`emp` TO `lab_a`@`%` |
+---------------------------------------------------------------------------------------------+
3 rows in set (0.00 sec)As root, GRANT SELECT (salary) ON hr.emp TO lab_a. SHOW GRANTS then shows salary in the SELECT list, and the UPDATE changed one row (lee → hq).
UPDATE hr.emp SET dept = 'hq' WHERE salary > 5000;
SELECT id, name, dept FROM hr.emp;Query OK, 1 row affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0
+----+------+-------+
| id | name | dept |
+----+------+-------+
| 1 | kim | sales |
| 2 | lee | hq |
+----+------+-------+
2 rows in set (0.00 sec)03Updating a column that has no UPDATE grant
UPDATE hr.emp SET salary = 4500 WHERE id = 1 failed with UPDATE command denied ... for column 'salary'. Only dept was granted for UPDATE.
Setup
CREATE DATABASE hr;
CREATE TABLE hr.emp (id INT PRIMARY KEY, name VARCHAR(20), dept VARCHAR(10), salary INT);
INSERT INTO hr.emp VALUES (1, 'kim', 'sales', 4200), (2, 'lee', 'dev', 5100);
GRANT SELECT (id, name, dept), UPDATE (dept) ON hr.emp TO lab_a;Query OK, 1 row affected (0.01 sec)
Query OK, 0 rows affected (0.01 sec)
Query OK, 2 rows affected (0.00 sec)
Records: 2 Duplicates: 0 Warnings: 0
Query OK, 0 rows affected (0.01 sec)UPDATE hr.emp SET salary = 4500 WHERE id = 1;ERROR 1143 (42000): UPDATE command denied to user 'lab_a'@'127.0.0.1' for column 'salary' in table 'emp'SELECT column_name, privilege_type FROM information_schema.column_privileges
WHERE table_schema = 'hr' AND table_name = 'emp' ORDER BY column_name, privilege_type;+-------------+----------------+
| column_name | privilege_type |
+-------------+----------------+
| dept | SELECT |
| dept | UPDATE |
| id | SELECT |
| name | SELECT |
+-------------+----------------+
4 rows in set (0.00 sec)UPDATE appears only for dept.
GRANT UPDATE (salary) ON hr.emp TO lab_a;Query OK, 0 rows affected (0.00 sec)As root, GRANT UPDATE (salary) ON hr.emp TO lab_a. The same UPDATE then affected 1 row.
UPDATE hr.emp SET salary = 4500 WHERE id = 1;
SELECT id, name, dept FROM hr.emp WHERE id = 1;Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
+----+------+-------+
| id | name | dept |
+----+------+-------+
| 1 | kim | sales |
+----+------+-------+
1 row in set (0.00 sec)FAQ
I can select some columns of the table. Why ERROR 1143 now?
With column-level grants, every column you read must be granted. In our test, listing only the granted columns worked; adding salary failed.
I have UPDATE on the column. Why "SELECT command denied"?
The WHERE clause read salary, which had no SELECT grant. After GRANT SELECT (salary), the same UPDATE succeeded.
How do I see which columns a user can access?
Query information_schema.column_privileges for the table, or run SHOW GRANTS FOR user. Both showed the column list in our test.
What is the difference between ERROR 1142 and 1143?
1142 is denied on the whole table. 1143 names a specific column, which means the user has column-level grants on that table.
How we verify
Each scenario starts from fresh database users. A script runs the setup, confirms the exact error code, applies the fix and runs the statement again. The output shown is what the database printed, saved by the script.
lab_a and lab_b are ordinary users created for the test, each with full rights on a database of the same name (its default database); root is the administrator. MySQL 8.4.13