Error 1045 means one thing: the connection reached the database, and the database refused the username and password pair. It is not a server that is down or a closed port: it is a credential that does not match. It nearly always takes ten minutes to fix, provided you look in the right order.
The full message carries two clues worth having: Access denied for user 'abc_user'@'localhost' (using password: YES). The name in quotes is the user the application actually used, and the YES or NO says whether any password was sent at all.
The causes, most likely first
| What the message shows |
The cause and the fix |
| A user with no account prefix (for example user instead of abc_user) |
In cPanel both the database name and the user name start with the account name. The application needs the full name, exactly as MySQL Databases shows it. |
| using password: YES |
The password sent is not this user’s. Someone changed it in cPanel and the configuration file kept the old one, or the copy came from another server with that server’s password. |
| using password: NO |
The application sent no password at all: the field is empty, the configuration file was not read, or the environment variable (.env) does not exist in this place. |
| The password contains quotes, $, # or @ |
The character broke the line of code or the connection address. Generate a new password using only letters and digits rather than fighting with escaping. |
| The address after the @ is not localhost |
The connection is not coming from the account itself. From outside, the database port is closed; see Remote MySQL and the SSH tunnel. |
Fixing it, step by step
| 2 |
Check the database name and user against what cPanel shows in MySQL Databases, letter by letter, prefix included. The host is localhost.
|
|
| 3 |
Do not guess the password: set a new one. In MySQL Databases, in the user list, choose to change the password, generate one and keep it. Paste exactly that into the file, with no stray spaces at the ends.
|
|
| 4 |
Confirm the user is linked to the database. Under Add User To Database join the two and grant the privileges. Without that link the error becomes 1044, described in Error 1044.
|
|
| 5 |
If you have SSH, prove the credentials away from the site: mysql -u abc_user -p abc_database asks for the password and tells you at once whether it gets in. If it does, the fault is in the application’s file and not in the database.
|
|
And on a VPS with your own database server?
The error Access denied for user 'root'@'localhost' is one of the most searched. On many installations (Ubuntu and Debian among them) the database root user does not log in with a password: it logs in through the operating system, with sudo mysql. Anyone typing an invented password gets the 1045. On a VPS these commands and the database server are yours; see how far our help goes in how far our support goes.
|
Rebuilt the user and the password and the 1045 is still there? Send us the full message, with the user name it shows.
Open a support ticket
|
RECOMMENDED PRODUCT Web hosting with cPanel Domain and SSL included, daily backups and the panel you already know. from $6.60/mo (3-year plan, with coupon) See plans |