MySQL Error 1133 - Can't find any matching row in the user table
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
MySQL Error 1133 (Can't find any matching row in the user table) occurs when you try to modify a user account that does not exist in the mysql.user table, or when the username and host combination does not match any existing row. This typically happens with SET PASSWORD, GRANT, ALTER USER, or RENAME USER statements when the specified 'user'@'host' pair is not found. The fix is to verify the exact username and host stored in the user table and use the correct combination, or create the user first if it does not exist.
When This Error Occurs
Diagnosing the Problem
Check which users actually exist:
The most common cause: the user was created with 'admin'@'%' (any host) but you are trying to modify 'admin'@'localhost' (localhost specifically). MySQL treats these as different user accounts.
Fix 1: Use the Correct Host
Fix 2: Create the Missing User
If the user does not exist at all, create it first:
Fix 3: After Modifying mysql.user Directly
If you manually inserted or updated rows in the mysql.user table, you must flush privileges:
Understanding MySQL Host Matching
MySQL authenticates users by both username AND host. These are all different accounts:
MySQL matches from most specific to least specific host:
- Exact hostname or IP (
'admin'@'192.168.1.10') - Wildcard pattern (
'admin'@'192.168.1.%') - Any host (
'admin'@'%')
Resetting Root Password
Error 1133 often appears when trying to reset the root password:
If root does not exist (corrupted installation):
Renaming Users
Common Pitfalls
- Confusing
'user'@'%'with'user'@'localhost': These are separate accounts in MySQL. A user created with@'%'does not match operations targeting@'localhost'. On many systems,localhostconnections use a Unix socket and match@'localhost'specifically, not@'%'. Check withSELECT User, Host FROM mysql.userbefore modifying. - Not running
FLUSH PRIVILEGESafter direct table edits: If you modify themysql.usertable directly withINSERTorUPDATEinstead of usingCREATE USERorALTER USER, MySQL does not reload the privilege tables. Always runFLUSH PRIVILEGESafter direct table modifications. - Anonymous user accounts interfering: An anonymous user (
''@'localhost') can take priority over'admin'@'%'for localhost connections. Check for anonymous accounts withSELECT User, Host FROM mysql.user WHERE User = ''and drop them if they cause issues. - Using
GRANTto create users in MySQL 8+: In MySQL 5.7 and earlier,GRANTimplicitly creates users. In MySQL 8.0+, you mustCREATE USERfirst, thenGRANT. RunningGRANTfor a non-existent user triggers Error 1133 in MySQL 8.0+. - Host resolution differences: If MySQL resolves
127.0.0.1tolocalhostor vice versa, the stored host may differ from what you expect. Useskip-name-resolveinmy.cnfto disable DNS resolution and always use IP addresses for consistency.
Summary
- Error 1133 means the
'user'@'host'combination does not exist inmysql.user - Always check the exact host value with
SELECT User, Host FROM mysql.user WHERE User = 'username' 'user'@'%'and'user'@'localhost'are different accounts — use the correct one- Create the user with
CREATE USERbefore granting privileges in MySQL 8.0+ - Run
FLUSH PRIVILEGESafter any direct modifications to themysql.usertable

