MariaDB

Anonymous User Blocking localhost Wildcard Logins

warning
Connection ManagementUpdated Feb 4, 2026

MariaDB/MySQL authentication checks the most specific host match first. An anonymous user entry for 'localhost' (e.g., ''@'localhost') can shadow a wildcard user account ('user'@'%'), preventing successful login from localhost even though the wildcard account exists and has a valid password.

How to detect:

Authentication failures for known users connecting from localhost with 'Access denied' errors. Query mysql.user table for both the intended user and anonymous entries: SELECT user, host FROM mysql.user WHERE user='<username>' OR user=''. If an anonymous ''@'localhost' entry exists and user@'%' does not have a specific localhost entry, the anonymous user is matched first.

Recommended action:

Create an explicit user account for localhost: CREATE USER 'user'@'localhost' IDENTIFIED BY 'password'; GRANT appropriate privileges; FLUSH PRIVILEGES;. Alternatively, remove the anonymous user: DROP USER ''@'localhost'; FLUSH PRIVILEGES;. Verify no other anonymous entries exist that could cause similar shadowing on other hostnames.