Error
Error Code:
1142
MariaDB Error 1142: Table Access Permission Denied
Description
This error indicates that a specific database command (e.g., SELECT, INSERT, UPDATE) was denied to a user when attempting to access a particular table. It occurs when the connecting user lacks the necessary privileges to perform the requested operation on the specified database object.
Error Message
%s command denied to user '%s'@'%s' for table '%s'
Known Causes
3 known causesInsufficient Table Privileges
The database user attempting the operation does not possess the required `SELECT`, `INSERT`, `UPDATE`, or `DELETE` privileges for the specified table.
Incorrect User or Host
The application is connecting with a user account that either doesn't exist or is defined for a different host, leading to a privilege check failure.
Missing Database-Level Privileges
The user account lacks broader database-level privileges that might be implicitly required for certain operations on tables within that database.
Solutions
2 solutions available1. Grant Required Privilege easy
Give user the specific permission needed
1
Grant specific command privilege
-- For SELECT
GRANT SELECT ON database_name.* TO 'username'@'host';
-- For INSERT
GRANT INSERT ON database_name.* TO 'username'@'host';
-- For UPDATE
GRANT UPDATE ON database_name.* TO 'username'@'host';
-- For DELETE
GRANT DELETE ON database_name.* TO 'username'@'host';
FLUSH PRIVILEGES;
2
Grant all basic CRUD privileges
GRANT SELECT, INSERT, UPDATE, DELETE ON database_name.* TO 'username'@'host';
FLUSH PRIVILEGES;
2. Check Current Privileges easy
View what user can and cannot do
1
Show grants for user
SHOW GRANTS FOR 'username'@'host';
2
Show current user privileges
SHOW GRANTS FOR CURRENT_USER();