1044ERRORTier 1 — Safe✅ HIGH confidence

Access denied for user to database

Category: Access ControlVersions: All MariaDB / MySQL versions

What this means

Error 1044 (SQLSTATE 42000) is returned when a user attempts to perform an operation on a database for which they have not been granted the required privilege. Unlike error 1045 which occurs at authentication, 1044 occurs after successful login when a specific database-level action is denied.

Why it happens

  1. 1The user account was created but no GRANT was issued for the target database
  2. 2The GRANT was issued on the wrong database name or with incorrect scope
  3. 3The user is connecting to a replica or a different server instance where grants have not been replicated

How to reproduce

A user with no database-level privileges attempts to USE a database.

trigger — this will ERROR
-- Run as a user without privileges on myapp_db
USE myapp_db;
ERROR 1044 (42000): Access denied for user 'appuser'@'localhost' to database 'myapp_db'

Fix 1: Grant the required privileges

When the user legitimately needs access to the database.

fix
-- Run as root or a privileged user
GRANT SELECT, INSERT, UPDATE, DELETE ON myapp_db.* TO 'appuser'@'localhost';
FLUSH PRIVILEGES;

Why this works

GRANT issues the named privileges on the specified objects to the user. FLUSH PRIVILEGES reloads the in-memory privilege tables from the grant tables, though in modern MariaDB versions explicit GRANT statements take effect immediately without FLUSH.

What not to do

Grant GRANT ALL PRIVILEGES ON *.* to silence the error

Why it's wrong: This gives the user superuser-equivalent access to every database on the server, violating the principle of least privilege.

Version notes

MariaDB 10.4+Password and account management changes mean some legacy grant syntax may behave differently. Use CREATE USER + GRANT in two steps.

Sources

📚 Official docs: https://mariadb.com/kb/en/grant/

🔧 Source ref: MariaDB Server error code 1044 / ER_DBACCESS_DENIED_ERROR

📖 Further reading: MariaDB privilege system overview

Confidence assessment

✅ HIGH confidence

Stable and well-documented across all MariaDB and MySQL versions.

See also

📄 Reference pages

GRANT statementMariaDB privilege system
⚙️ This error reference was generated with AI assistance and reviewed for accuracy. Examples are provided to illustrate common scenarios and may not cover every case. Always test fixes in a development environment before applying to production. Spotted an error? Suggest a correction →