.png&w=3840&q=75)
Websites & Hosting3 min
How to Fix MySQL Error 1045 (Access Denied for User)
NS
NameSilo Staff9/30/2026
Share
MySQL Error 1045 (Access Denied for User) occurs when your web application attempts to connect to the database using incorrect credentials or lacks the proper permissions. To fix it, verify that the database username, password, and host address in your configuration file (like wp-config.php) perfectly match the database credentials assigned inside your cPanel dashboard.
How Applications Authenticate with MySQL
Your website's application code never talks to MySQL using your cPanel login. Instead, a separate, dedicated database user account, with its own username and password, is created specifically for that purpose, and those exact credentials are stored in a configuration file (wp-config.php for WordPress, .env for many other frameworks).
Error 1045 means MySQL received a connection attempt and rejected it at the authentication stage. The exact message typically reads:
ERROR 1045 (28000): Access denied for user 'dbuser'@'localhost' (using password: YES)
Root Cause 1: Password Mismatches
Important clarification: your cPanel account login password and your MySQL database user password are two entirely separate credential systems. Changing one never changes or affects the other; this is a common misconception.
The real, common cause is simpler: someone resets the database user's password directly through cPanel's MySQL tool, perhaps while troubleshooting something else, or during a migration, and forgets to update the corresponding value inside wp-config.php to match. The application keeps trying the old password, MySQL keeps rejecting it.
Root Cause 2: Missing Privileges
This is the single most commonly missed step, and it produces the exact same error even when the username and password are both entered correctly.
Creating a database and creating a database user are two separate actions in cPanel. A third step, explicitly linking that user to that specific database and granting privileges, is required before the user can access it at all. Skip this "Add User To Database" step, and MySQL will reject every connection attempt from that user, regardless of how correct the password is, because the user simply isn't authorized to touch that database yet.
Implementation Steps
Step 1: In cPanel, go to MySQL Databases and locate the database user in question.
Step 2: Confirm the user appears under "Add User To Database" for the correct database. If it doesn't, add it now and grant All Privileges.
Step 3: If you need to reset the password anyway, do so under "Current Users," entering and confirming a new password.
Step 4: Open File Manager, locate wp-config.php (or your framework's equivalent config file), and update DB_USER, DB_PASSWORD, and DB_HOST to match exactly what cPanel shows.
Step 5: Save the file and reload your site to confirm the connection succeeds.
Common Mistakes
Leaving extra spaces or copying quote marks into the password field: Pasting a password copied from an email or notes app can accidentally include a trailing space or stray quotation mark. MySQL treats the password as literally different with even one extra character, so the connection fails despite the password "looking" correct.
What This Means for You
NameSilo Hosting includes full cPanel access, giving you direct control over MySQL Databases and File Manager to diagnose and resolve Error 1045 without waiting on a support ticket.
Frequently Asked Questions
What does MySQL Error 1045 mean?
The database rejected the connection due to incorrect credentials or missing permissions.
How do I fix access denied for user in MySQL?
Match your config file's credentials to cPanel's exactly, and confirm privileges are granted.
Where do I find my MySQL password in cPanel?
Passwords aren't stored in plain text; reset it under MySQL Databases if forgotten.
How do I grant all privileges to a MySQL user?
Under "Add User To Database" in cPanel, select the user, database, and check All Privileges.
What is a wp-config.php file?
WordPress's core configuration file, storing database connection credentials.
Can a server migration cause Error 1045?
Yes, if old credentials carried over don't match the new server's actual database user.
Why is my database connection failing?
Usually a credential mismatch or a user never granted access to that specific database.
Does NameSilo provide phpMyAdmin access?
Yes, included with cPanel on every NameSilo hosting plan.
.png&w=2048&q=75)
NameSilo StaffThe NameSilo staff of writers worked together on this post. It was a combination of efforts from our passionate writers that produce content to educate and provide insights for all our readers.
More articleswritten by NameSilo

.png&w=3840&q=75)
.png&w=3840&q=75)