dataiotech Labs
dbaguidedbaguideDBAdataxtoolsdataopsphere
Home/Error Library/mysql-1045-access-denied
MySQL
MySQL 8.0 / 8.4Authentication & Security
4 min read
ERROR 1045 (28000): Access denied for user 'root'@'localhost'

MySQL ERROR 1045 (28000): Access Denied — Root Cause and Safe Recovery

Four causes of MySQL 1045, meaning of using password: YES/NO, and safe credential recovery via --init-file.

Reviewed by:Senior Database Architect & SRE (dataiotech Labs)
Tested Versions: MySQL 8.0 / 8.4 LTS
First 60 Seconds Emergency Protocol:

The error string is a symptom, not the root cause. Do not restart the server blindly. Run the diagnostic queries below to pinpoint the actual failure mode.

▸Symptom

plaintext
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
  • •using password: NO: Password wasn't sent.
  • •using password: YES: Password sent but rejected by credentials or authentication plugin.

▸Safe Recovery with --init-file

Create a one-off SQL script:

sql
ALTER USER 'root'@'localhost' IDENTIFIED BY 'new-strong-password';

Restart daemon safely:

bash
sudo systemctl stop mysql sudo mysqld_safe --init-file=/tmp/reset.sql & sudo systemctl start mysql

Other Database Error Triage Playbooks

Other battle-tested diagnostic guides for high-severity database errors.

All Errors (20)