MySQL “Access denied for user”: check the account, reset the password
Check the account's host and plugin, then reset the password with ALTER USER.
Verify the exact 'user'@'host' row and its plugin in mysql.user, then reset the credential: ALTER USER 'root'@'localhost' IDENTIFIED BY 'new-password';. Match the host you connect from (localhost vs 127.0.0.1 are different accounts).
Try these fixes in order
Inspect the account rows
See every account row: the host and plugin columns explain most access-denied failures.
mysql -u root -p -e "SELECT user, host, plugin FROM mysql.user;"Reset the password
Replace 'new-password' with a strong password. This also works to switch the account back to a known credential.
mysql -u root -p -e "ALTER USER 'root'@'localhost' IDENTIFIED BY 'new-password';"Flush privileges
Account changes only take effect for new connections.
mysql -u root -p -e "FLUSH PRIVILEGES;"Reconnect and confirm
You should get a mysql> prompt instead of ERROR 1045.
mysql -u root -p -e "SELECT 1;"Interpret what you see
(using password: NO) or the host looks unexpected
What it suggests: MySQL distinguishes 'root'@'localhost' from 'root'@'127.0.0.1'; connecting over TCP when only the localhost account exists fails.
Next check: Query mysql.user for the exact user, host, and plugin rows.
Old client or connector version
What it suggests: MySQL 8 defaults to caching_sha2_password; very old clients that only speak mysql_native_password fail authentication.
Next check: Check the plugin column and either upgrade the client or alter the account's plugin deliberately.
You are unsure of the current password
What it suggests: The account may simply have a different password than the one being tried, or none at all.
Next check: Reset it with ALTER USER from a privileged session.
Why this happens
- The password is wrong, or the account uses a different authentication plugin than the client expects.
- The user@host combination does not exist; MySQL matches the full 'user'@'host' pair, not just the username.
Still not working?
Do not start mysqld with --skip-grant-tables and leave it running; it disables all authentication while active. Use it only briefly to reset credentials, then restart normally.
Official sources
These steps are based on the linked documentation and general diagnostics. BugMedic has not independently tested every product and system configuration. Review commands before running them.