MySQL error 1396: Operation CREATE USER failed
A user-management statement failed for the named account, most often CREATE USER for an account that exists or DROP USER for one that doesn't.
- Error number
1396- Name
ER_CANNOT_USER- SQLSTATE
HY000- Category
- Access and privileges
What it means
The message names the operation (CREATE USER, DROP USER, ALTER USER, RENAME USER) and the accounts it failed for. Remember that an account is user plus host: 'app'@'%' and 'app'@'localhost' are separate.
Common causes
- Creating an account that already exists.
- Dropping or altering an account that doesn't exist, often because of a different host part.
- Leftover rows from editing the
mysql.usertable directly in old versions.
How to fix it
-
Use the conditional forms.
CREATE USER IF NOT EXISTS 'app'@'%' IDENTIFIED BY 'strong-password'; DROP USER IF EXISTS 'old_app'@'%';
-
Check the exact account names.
SELECT user, host FROM mysql.user WHERE user LIKE 'app%';
Related errors
1045Access denied for user1449Definer user does not exist15025SQL Server: The server principal already exists
More access and privileges errors
1044Access denied for user to database1130Host is not allowed to connect1698Access denied for user (no password)1142Command denied to user for table1143Command denied to user for column1227Access denied; you need a privilege1419SUPER privilege needed with binary logging
The code and message text are from the MySQL 8.4 Error Message Reference. Browse the full MySQL error list or search every database error.
Work on MySQL in SQLly
A native SQL client for macOS, Windows and Linux with schema-aware IntelliSense, guardrails for risky statements and clear error messages, for MySQL and the other databases you use.