ERROR 1045 (28000): Access denied for user 'username'@'host' (using password: YE

MySQL 'Access Denied for User' Using Password Yes Fix

This nasty error shows when MySQL rejects your password. The fix is usually resetting the password or checking auth plugin settings. Let's get you back in.

Quick answer: Stop MySQL service, start it with --skip-grant-tables, connect without password, flush privileges, set new password with ALTER USER 'root'@'localhost' IDENTIFIED BY 'newpass';, then restart normally.

This error tripped me up the first time too. You're trying to log into MySQL, you type your password carefully, and boom — “Access denied for user 'root'@'localhost' (using password: YES)”. It's not just you. This happens a lot when MySQL uses a different authentication plugin than what your client expects. For example, MySQL 8.0 changed to caching_sha2_password, but older tools like PHP 5.6 or some phpMyAdmin versions still use mysql_native_password. Also, if you're on Ubuntu and used sudo apt install mysql-server, the root account often uses auth_socket — meaning it only logs in via sudo, not with a password at all.

Fix Steps — The Main Fix

  1. Stop the MySQL service. On Ubuntu or Debian: sudo systemctl stop mysql. On Windows (as admin): net stop MySQL80 (adjust version).
  2. Start MySQL without grant tables. This bypasses authentication. Run: sudo mysqld_safe --skip-grant-tables & (Linux) or mysqld --skip-grant-tables (Windows command prompt as admin).
  3. Connect without a password. Open another terminal and type: mysql -u root. No password needed now. You should see the MySQL prompt.
  4. Flush privileges. Inside MySQL, run: FLUSH PRIVILEGES;. This tells the server to reload the grant tables.
  5. Reset the password. For MySQL 8.0+, use: ALTER USER 'root'@'localhost' IDENTIFIED BY 'YourNewStrongPassword';. For older MySQL (5.x), use: SET PASSWORD FOR 'root'@'localhost' = PASSWORD('YourNewStrongPassword');.
  6. Flush again. Run FLUSH PRIVILEGES; one more time.
  7. Exit MySQL with EXIT;.
  8. Restart MySQL normally. Stop the skip-grant instance: sudo killall mysqld (Linux) or find the process in Task Manager (Windows). Then start: sudo systemctl start mysql (Linux) or net start MySQL80 (Windows).
  9. Test. Now connect: mysql -u root -p, then type your new password. It should work.

Alternative Fix — Auth Plugin Change

If the main fix didn't help, or you keep getting the error even with the right password, the problem is likely the authentication plugin. Your MySQL user might be set to auth_socket or caching_sha2_password, but your client expects the old mysql_native_password. Here's how to change it:

  1. Repeat steps 1-4 from the main fix to get into MySQL without password.
  2. Check what plugin your user uses: SELECT user, plugin FROM mysql.user WHERE user = 'root';. If it says auth_socket or caching_sha2_password, you need to switch it.
  3. Change the plugin and password together: ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'YourNewStrongPassword';. This forces MySQL to use the old native password system.
  4. Flush and restart as before.

Special case for Ubuntu: If the user shows auth_socket, you can keep it but only log in with sudo. That means: sudo mysql -u root (no password). It's annoying but some Linux distros do this by design.

Prevention Tips

  • Use the right auth plugin for your apps. If you're building a PHP app that runs on PHP 5.x or 7.0-7.2, always set your MySQL user to mysql_native_password. PHP's old mysqlnd library doesn't support caching_sha2_password.
  • Don't use root for apps. Create a dedicated user: CREATE USER 'myapp'@'localhost' IDENTIFIED BY 'mypass'; then grant specific privileges. Less risk of locking yourself out.
  • Keep passwords in a manager. I've seen admins type the wrong password for an hour. Use a password manager or store them in a secure file (with proper permissions).
  • Backup grant tables. Before making big changes, run: mysqldump --all-databases --flush-privileges > backup.sql. If you mess up, you can restore.

I know this error is infuriating, but trust me — the skip-grant-tables trick is like a master key for MySQL. Once you've done it a couple times, it becomes second nature. Good luck, and feel free to drop a comment if something's still broken.

Related Errors in Database Errors
0XC00D0FF0 Fix NS_E_WMP_SAVEAS_READONLY (0XC00D0FF0) in WMP 0X000013DF Fix 0X000013DF: Corrupt Cluster Database Backup 0X800F023A Fix SPAPI_E_PNP_REGISTRY_ERROR (0x800f023a) the Right Way 0X00001A40 Fix 0x1A40 Transaction Manager Name Collision on SQL Server

Was this solution helpful?

EP
Erropedia Team
Tech Support Editors
The Erropedia editorial team researches and documents real-world tech errors from across Windows, Linux, macOS, networking, databases, cloud platforms, and more. Every solution is reviewed for accuracy and updated as software and systems evolve.