MySQL 8.4Lab-verified · 2026-11-29

MySQL ERROR 1396 (HY000): Operation CREATE USER failed for 'app'@'%'

The account 'user'@'host' already exists (CREATE) or does not exist with that exact host (DROP/ALTER).

MySQL 8.4.13
1396 (HY000): Operation CREATE USER failed for 'app'@'%'

Jump to a cause

  1. 01CREATE USER for an account that already exists
  2. 02DROP USER without the host (it means '%')
  3. 03ALTER USER with a different host than the account

Lab-verifiedReproduced and fixed on MySQL 8.4.13 · 2026-11-29 · container image mysql:8.4

ERROR 1396 is returned by account statements such as CREATE USER, DROP USER and ALTER USER. A MySQL account is the pair 'user'@'host', so 'app'@'%' and 'app'@'localhost' are different accounts, and a name written without a host means 'name'@'%'.

The three runs below are the usual causes. First look at the real accounts: SELECT user, host FROM mysql.user WHERE user = 'name';.

01CREATE USER for an account that already exists

'app'@'%' had already been created, so running the same CREATE USER again returned ERROR 1396 (HY000): Operation CREATE USER failed for 'app'@'%'. This often happens when a setup script runs twice.

mysql.user showed app with host %. CREATE USER IF NOT EXISTS did not fail: it returned Query OK with 1 warning, and SHOW WARNINGS showed Note 3163 Authorization ID 'app'@'%' already exists.

Setup
Setuprun as root
DROP USER IF EXISTS 'app'@'%';
CREATE USER 'app'@'%' IDENTIFIED BY 'App#Pass1';
OUTPUT
Query OK, 0 rows affected, 1 warning (0.00 sec)

Query OK, 0 rows affected (0.01 sec)
Reproducerun as root
CREATE USER 'app'@'%' IDENTIFIED BY 'App#Pass1';
✕ ERROR
ERROR 1396 (HY000): Operation CREATE USER failed for 'app'@'%'
Checkrun as root
SELECT user, host FROM mysql.user WHERE user = 'app';
OUTPUT
+------+------+
| user | host |
+------+------+
| app  | %    |
+------+------+
1 row in set (0.00 sec)
After the fixrun as root
CREATE USER IF NOT EXISTS 'app'@'%' IDENTIFIED BY 'App#Pass1';
SHOW WARNINGS;
✓ SUCCESS
Query OK, 0 rows affected, 1 warning (0.00 sec)

+-------+------+--------------------------------------------+
| Level | Code | Message                                    |
+-------+------+--------------------------------------------+
| Note  | 3163 | Authorization ID 'app'@'%' already exists. |
+-------+------+--------------------------------------------+
1 row in set (0.00 sec)

02DROP USER without the host (it means '%')

The account was 'report'@'localhost'. DROP USER 'report' failed with Operation DROP USER failed for 'report'@'%'. The message shows that MySQL filled in % as the host.

mysql.user showed host localhost. DROP USER 'report'@'localhost' worked and the count of report rows in mysql.user became 0.

Setup
Setuprun as root
DROP USER IF EXISTS 'report'@'localhost';
CREATE USER 'report'@'localhost' IDENTIFIED BY 'Rep#Pass1';
OUTPUT
Query OK, 0 rows affected, 1 warning (0.00 sec)

Query OK, 0 rows affected (0.01 sec)
Reproducerun as root
DROP USER 'report';
✕ ERROR
ERROR 1396 (HY000): Operation DROP USER failed for 'report'@'%'
Checkrun as root
SELECT user, host FROM mysql.user WHERE user = 'report';
OUTPUT
+--------+-----------+
| user   | host      |
+--------+-----------+
| report | localhost |
+--------+-----------+
1 row in set (0.00 sec)
After the fixrun as root
DROP USER 'report'@'localhost';
SELECT COUNT(*) FROM mysql.user WHERE user = 'report';
✓ SUCCESS
Query OK, 0 rows affected (0.01 sec)

+----------+
| COUNT(*) |
+----------+
|        0 |
+----------+
1 row in set (0.00 sec)

03ALTER USER with a different host than the account

The batch account was created for '10.0.0.%'. Changing its password with ALTER USER 'batch'@'%' ... returned Operation ALTER USER failed for 'batch'@'%', because no 'batch'@'%' account exists.

mysql.user showed host 10.0.0.%. ALTER USER 'batch'@'10.0.0.%' IDENTIFIED BY ... worked.

Setup
Setuprun as root
DROP USER IF EXISTS 'batch'@'10.0.0.%';
CREATE USER 'batch'@'10.0.0.%' IDENTIFIED BY 'Bat#Pass1';
OUTPUT
Query OK, 0 rows affected, 1 warning (0.00 sec)

Query OK, 0 rows affected (0.00 sec)
Reproducerun as root
ALTER USER 'batch'@'%' IDENTIFIED BY 'Bat#Pass2';
✕ ERROR
ERROR 1396 (HY000): Operation ALTER USER failed for 'batch'@'%'
Checkrun as root
SELECT user, host FROM mysql.user WHERE user = 'batch';
OUTPUT
+-------+----------+
| user  | host     |
+-------+----------+
| batch | 10.0.0.% |
+-------+----------+
1 row in set (0.00 sec)
After the fixrun as root
ALTER USER 'batch'@'10.0.0.%' IDENTIFIED BY 'Bat#Pass2';
✓ SUCCESS
Query OK, 0 rows affected (0.01 sec)

FAQ

How do I fix ERROR 1396 Operation CREATE USER failed?

The account already exists. Check with SELECT user, host FROM mysql.user WHERE user = 'name';. Use CREATE USER IF NOT EXISTS in scripts, or ALTER USER if you meant to change the password.

Why does DROP USER say 'user'@'%' when I only typed the user name?

A user name without a host means 'name'@'%'. If the account is 'name'@'localhost', write the host: DROP USER 'name'@'localhost';.

Can I drop a user only if it exists in MySQL?

Yes, DROP USER IF EXISTS 'name'@'host';. The setup of each run above used it without an error.

Is the message translated when lc_messages is Korean or Japanese?

No. In MySQL 8.4 this error came out in English for all three languages in our runs.

How we verify

Each scenario starts from fresh database users. A script runs the setup, confirms the exact error code, applies the fix and runs the statement again. The output shown is what the database printed, saved by the script.

lab_a and lab_b are ordinary users created for the test, each with full rights on a database of the same name (its default database); root is the administrator. MySQL 8.4.13