How to fix ERROR 1141: No such grant defined for user in MySQL

MySQLINTERMEDIATEMEDIUMUpdated Dec 23, 2025ยท 173 views

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.

Quick fix

Fixes 1141

SELECT User, Host FROM mysql.user;
  1. Verify the exact user and host combination
  2. Check existing grants for the user
  3. Correct the REVOKE statement to match existing grants
  4. Use IF EXISTS clause for MySQL 8.0.30+
mysql โ€” error
SELECT User, Host FROM mysql.user;
ERROR 1141: No such grant defined for user

What this error means

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.

Typical symptoms

  • REVOKE statement fails with "ERROR 1141" when attempting to remove privileges
  • DROP USER or ALTER USER statements fail when managing grants
  • Administrative scripts that automatically revoke privileges fail unexpectedly
  • Error appears during database migration or user cleanup tasks
  • SHOW GRANTS for the user appears to have fewer privileges than expected

Common causes

  1. Attempting to revoke privileges that were never granted to the user@host combination
  2. Host mismatch: privileges exist for user@'%' but you're revoking for user@'localhost' (or vice versa)
  3. Typos in the username or hostname in the REVOKE statement
  4. Trying to revoke only specific privileges when privileges were granted globally (without partial_revokes enabled)
  5. Race condition in automated scripts that try to revoke privileges not yet confirmed to exist
  6. User created with one host but accessing from a different host
  7. Using wildcard hosts incorrectly when precise host matching is required

How to fix "ERROR 1141: No such grant defined for user"

1Verify the exact user and host combination

First, check what users and hosts actually exist in your MySQL instance:

sql
SELECT User, Host FROM mysql.user;

Look for the exact user@host combination you're working with. MySQL treats "user@localhost" and "user@10.0.0.1" as completely different accounts.

2Check existing grants for the user

Use SHOW GRANTS to see what privileges are actually assigned:

sql
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.

3Correct the REVOKE statement to match existing grants

Based on the output from SHOW GRANTS, craft your REVOKE statement to match what actually exists:

sql
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.

4Use IF EXISTS clause for MySQL 8.0.30+

If you're running MySQL 8.0.30 or later, use the IF EXISTS clause to make REVOKE operations more forgiving:

sql
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.

5Handle host mismatches

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:

sql
-- 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.

6Enable partial_revokes for schema-level revocation (MySQL 8.0.16+)

If you have global privileges and want to revoke privileges only for specific databases, enable partial_revokes:

sql
SET GLOBAL partial_revokes = ON;

Then you can revoke database-specific privileges:

sql
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.

7Flush privileges if needed

After making privilege changes, flush the privilege cache to ensure changes take effect immediately:

sql
FLUSH PRIVILEGES;

While MySQL usually applies privilege changes immediately, explicitly flushing ensures all connections see the updated permissions.

Advanced notes

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.

Frequently asked questions

What does "1141" mean?
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.
How do I fix "1141"?
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.
What causes "1141"?
Attempting to revoke privileges that were never granted to the user@host combination Host mismatch: privileges exist for user@'%' but you're revoking for user@'localhost' (or vice versa) Typos in the username or hostname in the REVOKE statement
Is the "1141" error serious?
It is a medium-severity error โ€” more of a blocker than a risk. The steps above resolve it.

Official resources & further reading