// MySQL error reference

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
Error message
Operation %s failed for %s

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.user table directly in old versions.

How to fix it

  1. Use the conditional forms.

    CREATE USER IF NOT EXISTS 'app'@'%' IDENTIFIED BY 'strong-password';
    DROP USER IF EXISTS 'old_app'@'%';
  2. Check the exact account names.

    SELECT user, host FROM mysql.user WHERE user LIKE 'app%';

Related errors

More access and privileges errors

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.

// fewer errors, faster fixes

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.