MySQL error 1044 occurs when a user lacks sufficient privileges to access a specified database. The user can connect to the MySQL server but does not have permission to use the database. Fix this by granting proper privileges using GRANT statements and FLUSH PRIVILEGES.
ERROR 1044 (42000) is a permission-based error that occurs when a MySQL user attempts to perform an operation on a database they do not have access to. Unlike error 1045 which indicates authentication failure (wrong password), error 1044 means the user is successfully authenticated but lacks the necessary privileges to perform the requested action on the specified database. This commonly happens when importing databases, creating users without proper privileges, or using shared hosting where database naming conventions must be followed. The error format typically shows: "ERROR 1044 (42000): Access denied for user 'username'@'hostname' to database 'database_name'". The key distinction is that authentication succeeded, but authorization failed.
Connect to MySQL as a user with administrative privileges (usually root) and check what permissions the affected user has:
SHOW GRANTS FOR 'username'@'hostname';If the output shows only GRANT USAGE ON *.* TO 'username'@'hostname', the user has no actual permissions.
Note: Replace 'username' with the actual MySQL user and 'hostname' with where they connect from (localhost, 127.0.0.1, %, etc.).
If the user lacks permissions, grant them using the GRANT statement:
GRANT ALL PRIVILEGES ON database_name.* TO 'username'@'hostname';
FLUSH PRIVILEGES;For more restrictive permissions, grant only specific privileges:
GRANT SELECT, INSERT, UPDATE, DELETE ON database_name.* TO 'username'@'hostname';
FLUSH PRIVILEGES;Important: Always include FLUSH PRIVILEGES; after GRANT to apply the changes immediately.
If the user does not exist, create it first before granting privileges (required in MySQL 8.0+):
CREATE USER 'username'@'hostname' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON database_name.* TO 'username'@'hostname';
FLUSH PRIVILEGES;For remote connections from any host, use the wildcard hostname:
CREATE USER 'username'@'%' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON database_name.* TO 'username'@'%';
FLUSH PRIVILEGES;Confirm the privileges were granted correctly:
SHOW GRANTS FOR 'username'@'hostname';You should now see entries like:
GRANT ALL PRIVILEGES ON `database_name`.* TO `username`@`hostname`
GRANT USAGE ON *.* TO `username`@`hostname`Then reconnect with the user account and attempt the operation that was failing.
If you are on shared hosting, database naming must follow the pattern: cpaneluser_databasename
Create databases through the hosting control panel (cPanel MySQL Database tool or Plesk) rather than SQL commands. If you are importing a .sql file, remove any CREATE DATABASE or USE statements from the file before import, as shared hosting users cannot execute those commands.
Edit your backup .sql file and remove or comment out lines like:
-- DROP DATABASE IF EXISTS database_name;
-- CREATE DATABASE database_name;
-- USE database_name;Then import the remaining content into your existing database.
MySQL treats localhost (socket connection) and 127.0.0.1 (TCP/IP) as different hosts.
If connecting from an application and getting error 1044, verify your connection string uses the same hostname as your GRANT statement. If your user is:
CREATE USER 'app'@'localhost' IDENTIFIED BY 'password';But your application connects to 127.0.0.1, create another user or grant both:
GRANT ALL PRIVILEGES ON database_name.* TO 'app'@'localhost';
GRANT ALL PRIVILEGES ON database_name.* TO 'app'@'127.0.0.1';
FLUSH PRIVILEGES;Or use the wildcard:
GRANT ALL PRIVILEGES ON database_name.* TO 'app'@'%';
FLUSH PRIVILEGES;Least Privilege Principle: Granting ALL PRIVILEGES is convenient for development but not recommended for production. Create a dedicated user for each application and grant only required privileges (e.g., SELECT, INSERT, UPDATE, DELETE for a web app; SELECT only for reporting tools).
MySQL 8.0 Changes: In MySQL 8.0+, you cannot create a user via GRANT directly (will raise ERROR 1410). You must CREATE USER first, then GRANT permissions.
Password Hashing: MySQL 8.0 uses caching_sha2_password by default. If your client library is older, you may need to use mysql_native_password: ALTER USER 'username'@'hostname' IDENTIFIED WITH mysql_native_password BY 'password';
Database-Level vs Table-Level Permissions: GRANT ALL PRIVILEGES ON database.* applies to all tables. For finer control, grant table-specific permissions: GRANT SELECT, INSERT ON database.table_name TO 'user'@'host';
Grant Option: If you need the user to grant permissions to other users, add WITH GRANT OPTION: GRANT ALL PRIVILEGES ON database.* TO 'user'@'host' WITH GRANT OPTION;
EE_WRITE (3): Error writing file
How to fix "EE_WRITE (3): Error writing file" in MySQL
CR_PARAMS_NOT_BOUND (2031): No data supplied for parameters
How to fix "CR_PARAMS_NOT_BOUND (2031): No data supplied for parameters" in MySQL
CR_DNS_SRV_LOOKUP_FAILED (2070): DNS SRV lookup failed
How to fix "CR_DNS_SRV_LOOKUP_FAILED (2070): DNS SRV lookup failed" in MySQL
ERROR 1146: Table 'database.table' doesn't exist
How to fix "ERROR 1146: Table doesn't exist" in MySQL
ERROR 1040: Too many connections
How to fix "ERROR 1040: Too many connections" in MySQL