Lab-verifiedReproduced and fixed on MySQL 8.4.13 · 2026-11-30 · container image mysql:8.4
ERROR 1044 is a database-level access error. The user and password were accepted (a bad password would be ERROR 1045); the account just has no grant on the named database, whether that name comes from the connection settings or from the statement it ran.
The four runs below are the usual cases. Start with SHOW GRANTS FOR 'user'@'host'; as an admin to see what the account actually has.
01USE on a database the account has no grant for
lab_b only had privileges on its own database. USE shop failed with ERROR 1044 (42000): Access denied for user 'lab_b'@'%' to database 'shop'.
SHOW GRANTS showed only USAGE ON *.* and ALL ON lab_b.*. After root ran GRANT SELECT ON shop.* TO lab_b, USE shop worked and SELECT * FROM orders returned the row.
Setup
CREATE DATABASE shop;
CREATE TABLE shop.orders (id INT PRIMARY KEY, amount DECIMAL(10,2));
INSERT INTO shop.orders VALUES (1, 100.00);Query OK, 1 row affected (0.00 sec)
Query OK, 0 rows affected (0.02 sec)
Query OK, 1 row affected (0.01 sec)USE shop;ERROR 1044 (42000): Access denied for user 'lab_b'@'%' to database 'shop'SHOW GRANTS FOR lab_b;+--------------------------------------------------+
| Grants for lab_b@% |
+--------------------------------------------------+
| GRANT USAGE ON *.* TO `lab_b`@`%` |
| GRANT ALL PRIVILEGES ON `lab_b`.* TO `lab_b`@`%` |
+--------------------------------------------------+
2 rows in set (0.00 sec)GRANT SELECT ON shop.* TO lab_b;Query OK, 0 rows affected (0.00 sec)USE shop;
SELECT * FROM orders;+----+--------+
| id | amount |
+----+--------+
| 1 | 100.00 |
+----+--------+
1 row in set (0.00 sec)02Wrong database name when connecting (JDBC URL, -D, DB_NAME)
app_user had ALL ON shop.*, but the connection asked for database shop_db. The login was refused with Access denied for user 'app_user'@'%' to database 'shop_db', which is what an app sees when the database name in its connection settings is wrong.
Note that shop_db does not exist, yet the error is 1044, not 1049 (Unknown database): for an account without rights on that name, MySQL reports access denied. SHOW DATABASES LIKE 'shop%' showed only shop, and SHOW GRANTS showed the grant on shop.*. Connecting with database shop worked and the SELECT returned the row.
Setup
CREATE DATABASE shop;
CREATE TABLE shop.orders (id INT PRIMARY KEY, amount DECIMAL(10,2));
INSERT INTO shop.orders VALUES (1, 100.00);
CREATE USER 'app_user'@'%' IDENTIFIED BY 'App_Pw_2026';
GRANT ALL ON shop.* TO 'app_user'@'%';Query OK, 1 row affected (0.00 sec)
Query OK, 0 rows affected (0.02 sec)
Query OK, 1 row affected (0.00 sec)
Query OK, 0 rows affected (0.01 sec)
Query OK, 0 rows affected (0.00 sec)$ mysql -h 127.0.0.1 -u app_user -p'App_Pw_2026' shop_dbSELECT * FROM orders;ERROR 1044 (42000): Access denied for user 'app_user'@'%' to database 'shop_db'SHOW DATABASES LIKE 'shop%';
SHOW GRANTS FOR 'app_user'@'%';+------------------+
| Database (shop%) |
+------------------+
| shop |
+------------------+
1 row in set (0.00 sec)
+----------------------------------------------------+
| Grants for app_user@% |
+----------------------------------------------------+
| GRANT USAGE ON *.* TO `app_user`@`%` |
| GRANT ALL PRIVILEGES ON `shop`.* TO `app_user`@`%` |
+----------------------------------------------------+
2 rows in set (0.00 sec)$ mysql -h 127.0.0.1 -u app_user -p'App_Pw_2026' shopSELECT * FROM orders;+----+--------+
| id | amount |
+----+--------+
| 1 | 100.00 |
+----+--------+
1 row in set (0.00 sec)03CREATE DATABASE without the global CREATE privilege
CREATE DATABASE report as lab_b failed with ERROR 1044 for database 'report'. Creating a new database needs CREATE on that database name, which lab_b did not have.
root created the database and ran GRANT ALL ON report.* TO lab_b. Then lab_b could create report.daily, and SHOW TABLES FROM report listed it.
CREATE DATABASE report;ERROR 1044 (42000): Access denied for user 'lab_b'@'%' to database 'report'CREATE DATABASE report;
GRANT ALL ON report.* TO lab_b;Query OK, 1 row affected (0.01 sec)
Query OK, 0 rows affected (0.00 sec)CREATE TABLE report.daily (d DATE PRIMARY KEY, total INT);
SHOW TABLES FROM report;Query OK, 0 rows affected (0.01 sec)
+------------------+
| Tables_in_report |
+------------------+
| daily |
+------------------+
1 row in set (0.00 sec)04LOCK TABLES with only SELECT (mysqldump error)
lab_b had SELECT on shop.*, but LOCK TABLES shop.orders READ failed with ERROR 1044. This is the same check that makes mysqldump stop with when using LOCK TABLES, because mysqldump locks tables by default.
SHOW GRANTS showed SELECT ON shop.* only. After GRANT LOCK TABLES ON shop.* TO lab_b, LOCK TABLES and UNLOCK TABLES both returned Query OK.
Setup
CREATE DATABASE shop;
CREATE TABLE shop.orders (id INT PRIMARY KEY, amount DECIMAL(10,2));
GRANT SELECT ON shop.* TO lab_b;Query OK, 1 row affected (0.00 sec)
Query OK, 0 rows affected (0.01 sec)
Query OK, 0 rows affected (0.00 sec)LOCK TABLES shop.orders READ;ERROR 1044 (42000): Access denied for user 'lab_b'@'%' to database 'shop'SHOW GRANTS FOR lab_b;+--------------------------------------------------+
| Grants for lab_b@% |
+--------------------------------------------------+
| GRANT USAGE ON *.* TO `lab_b`@`%` |
| GRANT SELECT ON `shop`.* TO `lab_b`@`%` |
| GRANT ALL PRIVILEGES ON `lab_b`.* TO `lab_b`@`%` |
+--------------------------------------------------+
3 rows in set (0.00 sec)GRANT LOCK TABLES ON shop.* TO lab_b;Query OK, 0 rows affected (0.00 sec)LOCK TABLES shop.orders READ;
UNLOCK TABLES;Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)FAQ
What is the difference between ERROR 1044 and ERROR 1045?
1045 means the user, host and password did not match any account. 1044 means they matched, but the account has no privilege on that database, either the one in the connection settings or the one in the statement.
I get 1044 for a database that doesn't exist. Why not 1049 Unknown database?
For an account with no rights on that name, MySQL answers with access denied (1044). In our run connecting to the nonexistent shop_db gave 1044. Check the database name in your connection settings.
How do I see which databases a MySQL user can access?
As an admin run SHOW GRANTS FOR 'user'@'host';. In the runs above it showed lines like GRANT SELECT ON shop.* TO lab_b.
mysqldump fails with 1044 when using LOCK TABLES. How do I fix it?
Give the dump user LOCK TABLES on the database: GRANT LOCK TABLES ON shop.* TO 'user'@'host';. In our run that made LOCK TABLES work.
Do I need FLUSH PRIVILEGES after GRANT?
Not for GRANT. In the runs above the new grant worked right away in the next session without FLUSH PRIVILEGES.
How we verify
Each scenario starts from fresh database users. A script runs the setup, confirms the exact error code, applies the fix and runs the statement again. The output shown is what the database printed, saved by the script.
lab_a and lab_b are ordinary users created for the test, each with full rights on a database of the same name (its default database); root is the administrator. MySQL 8.4.13