1044
MariaDBERRORCommonAccess ControlHIGH confidence

Access denied for user to database

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
trigger — this will error
-- Run as a user without privileges on myapp_db
USE myapp_db;

expected output

ERROR 1044 (42000): Access denied for user 'appuser'@'localhost' to database 'myapp_db'

Fix

Grant the required privileges

WHEN When the user legitimately needs access to the database.

Grant the required privileges
-- 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

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 documentation ↗

MariaDB Server error code 1044 / ER_DBACCESS_DENIED_ERROR

MariaDB privilege system overview

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

← All MariaDB errors