mysqldude
Error codes › 1044

MySQL & MariaDB error 1044: Access denied for user to database

Error messageAccess denied for user '…'@'…' to database '…'
Example from our test runs: Access denied for user 'appuser'@'%' to database 't_0' (5.6.51)

The login worked, but the account has no privileges on the database it tried to use or create. Different from 1045, which is a failed login.

MySQLMariaDB
SymbolER_DBACCESS_DENIED_ERRORER_DBACCESS_DENIED_ERROR
SQLSTATE4200042000
TypeServer errorServer error
Versionsevery release since 5.0 activeevery release since 5.5 active

What it means

Access denied for user 'appuser'@'%' to database 'shop'. Authentication succeeded, so the user name and password are fine. The account can’t USE, CREATE or otherwise access that database.

Why it happens

  • The account was created but never granted privileges on that database.
  • Grants exist for a different database name. Wildcards in grants (shop_%) treat _ as a single-character wildcard, so they may not match what you expect.
  • Trying to CREATE DATABASE without the global CREATE privilege (common on shared hosting).
  • The grant is on a different account (host) from the one you logged in as.

How to fix it

  • SHOW GRANTS; (as that user) shows exactly what you have; SELECT CURRENT_USER(); shows which account you are.
  • As an admin: GRANT SELECT, INSERT, UPDATE, DELETE ON shop.* TO 'appuser'@'%';
  • On shared hosting, create databases through the control panel; the account usually can’t.

Reproduce it yourself

These steps are the exact test our harness runs. Use a scratch server, never production.

  1. Connect with mysql -u root -p and create a scratch database:

    CREATE DATABASE demo;
    USE demo;
  2. Run:

    CREATE USER 'appuser'@'%' IDENTIFIED BY 'Test#1234';
  3. In a shell on the database host:

    mysql -uappuser -p'Test#1234' -h127.0.0.1 -e 'USE demo'

You get: ERROR 1044 (42000) at line 1: Access denied for user 'appuser'@'%' to database 't_0'(11.8.9)

Verified fixes

  1. Grant privileges on the database, then check with SHOW GRANTS

    CREATE USER 'appuser'@'%' IDENTIFIED BY 'Test#1234';
    GRANT SELECT ON demo.* TO 'appuser'@'%';
    mysql -uappuser -p'Test#1234' -h127.0.0.1 -N -e 'USE demo; SELECT DATABASE()'

Tested on

StepMySQLMariaDB
5.65.78.08.4910.610.1111.411.8
Use a database the account has no privileges on
repro
✓ 1044✓ 1044✓ 1044✓ 1044✓ 1044✓ 1044✓ 1044✓ 1044✓ 1044
Grant privileges on the database, then check with SHOW GRANTS
fix
✓✓✓✓✓✓✓✓✓
Use a database the account has no privileges on repro
MySQL 5.6✓ 10445.7✓ 10448.0✓ 10448.4✓ 10449✓ 1044
MariaDB 10.6✓ 104410.11✓ 104411.4✓ 104411.8✓ 1044
Grant privileges on the database, then check with SHOW GRANTS fix
MySQL 5.6✓5.7✓8.0✓8.4✓9✓
MariaDB 10.6✓10.11✓11.4✓11.8✓
✓works ✓ 1062fails with the error the step demonstrates ⚠works with a warning ≠runs, result differs ✗fails Tested 2026-11-25 on 5.6.51, 5.7.44, 8.0.46, 8.4.13, 9.7.4, 10.6.28, 10.11.19, 11.4.13, 11.8.9

Related errors

  • 1045 ER_ACCESS_DENIED_ERRORexplained
  • 1142 ER_TABLEACCESS_DENIED_ERRORexplained
  • 1227 ER_SPECIFIC_ACCESS_DENIED_ERRORexplained