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.
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
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:
ALTER USER 'root'@'localhost' IDENTIFIED BY 'new-strong-password';Restart daemon safely:
sudo systemctl stop mysql
sudo mysqld_safe --init-file=/tmp/reset.sql &
sudo systemctl start mysql- •MySQL Backup & Recovery CheatSheet
- •Validated versions: MySQL 8.0 / 8.4 LTS
Other Database Error Triage Playbooks
Other battle-tested diagnostic guides for high-severity database errors.
MySQL Deadlock ERROR 1213: Graph Analysis and Permanent Prevention
Root causes of MySQL 1213 deadlock, parsing LATEST DETECTED DEADLOCK output, gap lock concurrency issues, and resilient application retry design.
MySQL Lock wait timeout exceeded: Finding Blocking Sessions
Finding the blocking transaction using performance_schema, safe KILL decision matrices, and permanent locking reduction.
MySQL 1452 Foreign Key Constraint Fails: Cause and Fix
Distinction between 1452 and 1451, charset and data type mismatch, finding orphan rows, and safe bulk data loading procedures.