1948
MySQLERRORNotableSecurityHIGH confidence

There is no such user

Production Risk

Low — grant is rejected; no privilege changes occur.

What this means

A SQL statement references a user account that does not exist in the mysql.user table. This can occur with GRANT, REVOKE, ALTER USER, or similar DDL statements targeting a non-existent user.

Why it happens
  1. 1GRANT ... TO 'user'@'host' where the user account has not been created.
  2. 2REVOKE from a user that was already dropped.
  3. 3Typo in the username or host portion.
How to reproduce
trigger — this will error
trigger — this will error
GRANT SELECT ON db.* TO 'ghost_user'@'%'; -- user does not exist

expected output

ERROR 1948 (HY000): There is no such user 'ghost_user'@'%'.

Fix

Create the user before granting privileges

Create the user before granting privileges
CREATE USER 'ghost_user'@'%' IDENTIFIED BY 'password';
GRANT SELECT ON db.* TO 'ghost_user'@'%';

Why this works

MySQL 8.0 requires the account to exist before privileges can be granted unless using CREATE USER ... GRANT.

What not to do

Version notes

Sources
Official documentation ↗

MySQL 8.0 — 1948 ER_NO_SUCH_USER

Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev

← All MySQL errors