Error
Error Code: 1044

MySQL Error 1044: User Database Access Denied

📦 MySQL
📋

Description

MySQL Error 1044 indicates that a specified user account attempted to access a database but was denied permission. This typically occurs when the user lacks the necessary privileges, provides incorrect credentials, or connects from an unauthorized host.
💬

Error Message

Access denied for user '%s'@'%s' to database '%s'
🔍

Known Causes

4 known causes
⚠️
Incorrect User Credentials
The username or password provided during the connection attempt does not match an existing user record or is incorrect.
⚠️
Insufficient Database Privileges
The user account exists but does not have the required permissions (e.g., SELECT, INSERT) on the specific target database.
⚠️
Restricted Host Access
The user account is configured to allow connections only from specific hosts or IP addresses, and the current connection source is not permitted.
⚠️
User Account Does Not Exist
The user account specified in the connection string has not been created on the MySQL server.
🛠️

Solutions

4 solutions available

1. Grant Database Access easy

Give user permission to access the database

1
Connect as admin/root user
mysql -u root -p
2
Grant all privileges on specific database
GRANT ALL PRIVILEGES ON database_name.* TO 'username'@'localhost';
FLUSH PRIVILEGES;
3
Verify grants were applied
SHOW GRANTS FOR 'username'@'localhost';

2. Grant Specific Privileges medium

Give only required permissions

1
Grant read-only access
GRANT SELECT ON database_name.* TO 'username'@'localhost';
FLUSH PRIVILEGES;
2
Grant CRUD operations
GRANT SELECT, INSERT, UPDATE, DELETE ON database_name.* TO 'username'@'localhost';
FLUSH PRIVILEGES;
3
Grant with schema modification rights
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER, INDEX, DROP 
ON database_name.* TO 'username'@'localhost';
FLUSH PRIVILEGES;

3. Check User Host Mismatch medium

User might have different host than expected

1
Check all entries for this user
SELECT User, Host FROM mysql.user WHERE User = 'username';
2
Check grants for specific host
SHOW GRANTS FOR 'username'@'%';
SHOW GRANTS FOR 'username'@'localhost';
3
Grant access for correct host
GRANT ALL PRIVILEGES ON database_name.* TO 'username'@'%';
FLUSH PRIVILEGES;

4. Create User with Database Access easy

Create new user if doesn't exist

1
Create user and grant access in one step
CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON database_name.* TO 'newuser'@'localhost';
FLUSH PRIVILEGES;
🔗

Related Errors

5 related errors