Skip to the fix
PHPSolvedThe fix first, then the reason

Newest fixes

Fixes for PHP, MySQL and the server around them

Paste the error, read the answer at the top of the page, then the reason. Code blocks that could be run were run, and each one says on which version.

Radovan Sykora in MySQL | | 5 min

MySQL error 1396: CREATE USER or DROP USER failed, and how to clean up

A wooden wall rack holding one blank card

The message doesn't say what's wrong, only which operation and which account:

sqlran on MySQL 8.0.33
DROP USER IF EXISTS 'lab_anna'@'localhost', 'lab_anna'@'%';
CREATE USER 'lab_anna'@'localhost' IDENTIFIED BY 'first password';
sqlfails on purpose, MySQL 8.0.33
CREATE USER 'lab_anna'@'localhost' IDENTIFIED BY 'second password';
real output
ERROR 1396 (HY000) at line 1: Operation CREATE USER failed for 'lab_anna'@'localhost'

In nearly all cases the reason is simple: for CREATE USER the account exists, for DROP USER and ALTER USER it doesn't. What makes it confusing is that an account is a name and a host together, and the part you didn't type is filled in for you.

Look at what is there, both columns:

sqlran on MySQL 8.0.33
SELECT user, host, plugin, account_locked FROM mysql.user WHERE user = 'lab_anna';
real output
+----------+-----------+-----------------------+----------------+
| user     | host      | plugin                | account_locked |
+----------+-----------+-----------------------+----------------+
| lab_anna | localhost | caching_sha2_password | N              |
+----------+-----------+-----------------------+----------------+

All runs are on MySQL 8.0.33. MariaDB uses the same number and text.

Read the whole fix

More fixes

Every fix, newest first

Short notes on the old addresses

By subject