This error occurs when attempting to revoke or modify privileges for a user@host combination where no grant exists. It typically results from host mismatches, typos, or attempting to revoke privileges that were never granted. Verify the exact user and host, check existing grants, and ensure your REVOKE syntax matches an actual privilege assignment.
MySQL Error 1141 (ER_NONEXISTING_GRANT) is thrown when you attempt to revoke, modify, or display privileges for a user@host combination that does not exist in the MySQL privilege tables. This error indicates that the server cannot find the requested privilege entry for the given user and host. Unlike other errors that involve missing users entirely, Error 1141 specifically means the user exists but the privilege grant you are trying to revoke was never granted in the first place. MySQL maintains user privileges in the mysql.user table (global level) and mysql.db table (database level). When you try to revoke a privilege that is not recorded in these tables for a specific user@host pair, the server returns this error.
First, check what users and hosts actually exist in your MySQL instance:
SELECT User, Host FROM mysql.user;Look for the exact user@host combination you're working with. MySQL treats "user@localhost" and "[email protected]" as completely different accounts.
Use SHOW GRANTS to see what privileges are actually assigned:
SHOW GRANTS FOR 'username'@'hostname';Replace username and hostname with your actual values (keep the quotes). This command shows you exactly what privileges exist for this user@host, so you know what can be revoked.
Based on the output from SHOW GRANTS, craft your REVOKE statement to match what actually exists:
REVOKE SELECT, INSERT ON database.* FROM 'username'@'hostname';Ensure the specific privileges you're revoking are listed in the SHOW GRANTS output. Do not attempt to revoke privileges that don't appear there.
If you're running MySQL 8.0.30 or later, use the IF EXISTS clause to make REVOKE operations more forgiving:
REVOKE IF EXISTS SELECT, INSERT ON database.* FROM 'username'@'hostname';This will issue a warning instead of an error if the privilege doesn't exist, allowing your scripts to continue without failure.
If privileges exist for a wildcard host ('user'@'%') but you're trying to revoke for a specific host ('user'@'localhost'), you need to revoke from the wildcard:
-- This will fail if grant exists only for '%'
REVOKE SELECT ON database.* FROM 'user'@'localhost';
-- This is what you actually need
REVOKE SELECT ON database.* FROM 'user'@'%';Always match the exact host in your REVOKE statement to where the privileges were originally granted.
If you have global privileges and want to revoke privileges only for specific databases, enable partial_revokes:
SET GLOBAL partial_revokes = ON;Then you can revoke database-specific privileges:
REVOKE SELECT ON mydb.* FROM 'user'@'%';This is only necessary if you previously granted global privileges and now want to restrict them to specific databases.
After making privilege changes, flush the privilege cache to ensure changes take effect immediately:
FLUSH PRIVILEGES;While MySQL usually applies privilege changes immediately, explicitly flushing ensures all connections see the updated permissions.
When designing automated systems that manage grants, always use SHOW GRANTS to query actual privileges before attempting REVOKE. Some systems (Ansible, Terraform) have encountered Error 1141 when they assumed privileges matched a particular pattern without verification.
For security best practices, avoid granting global privileges (GRANT ALL ON *.*). Instead, grant privileges to specific databases and tables. This reduces the complexity of privilege management and lowers the chance of encountering partial_revokes issues.
MariaDB and MySQL handle wildcard hosts differently in some edge cases. If migrating between them, always test privilege operations thoroughly. The error message format is identical, but the underlying behavior with host patterns may vary.
In replication scenarios, if the primary and replica have different privilege setups, Error 1141 can appear on the replica during replication if the primary executes a REVOKE that doesn't apply to the replica's user configuration. Use binary log filtering or ensure privilege tables are identical across instances.
ERROR 1064: You have an error in your SQL syntax
How to fix "ERROR 1064: You have an error in your SQL syntax" in MySQL
ERROR 1054: Unknown column in field list
Unknown column in field list
ER_WINDOW_RANGE_FRAME_NUMERIC_TYPE (3589): RANGE frame requires numeric ORDER BY expression
RANGE frame requires numeric ORDER BY expression in MySQL window functions
CR_ALREADY_CONNECTED (2058): Handle already connected
How to fix "CR_ALREADY_CONNECTED (2058): Handle already connected" in MySQL
ER_WINDOW_DUPLICATE_NAME (3591): Duplicate window name
How to fix ER_WINDOW_DUPLICATE_NAME (3591) in MySQL window functions