How to reset the Debian Maintenance password.
Reset Instructions
Before you begin, copy the existing password in the file, and make a full AMI image backup.
Step 1. It is easiest to proceed from SSH CLI.
Step 2. Assuming you have not changed your MySQL Root Password or changed EC2 IDs please login with root mysql credentials.
mysql -u root -p
Step 3. After you log into MySQL, issue the following commands at the mysql prompt. Make sure you copy down the new password you are issuing, you’ll need it again. You are issuing a new password and not just copying the text below.
MySQL 8.0
1. ALTER USER 'debian-sys-maint'@'localhost' IDENTIFIED WITH caching_sha2_password BY 'TO_NEW_PASSWORD';
2. ALTER USER 'debian-sys-maint'@'localhost' IDENTIFIED BY 'TO_NEW_PASSWORD' PASSWORD EXPIRE NEVER;
3. ALTER USER 'debian-sys-maint'@'localhost' IDENTIFIED WITH mysql_native_password BY 'TO_NEW_PASSWORD';
MySQL 5.7
UPDATE mysql.user
SET authentication_string = PASSWORD('TO_NEW_PASSWORD'), password_expired = 'N' WHERE User = 'debian-sys-maint' AND Host = 'localhost';
FLUSH PRIVILEGES;
exit
Step 4. From the password you set earlier update the debian.cnf file in the section that says “password =” Set to your new password and save.
sudo nano /etc/mysql/debian.cnf
# Automatically generated for Debian scripts. DO NOT TOUCH! [client]
host = localhost
user = debian-sys-maint
password = NEWPASSWORD
socket = /var/run/mysqld/mysqld.sock
[mysql_upgrade]
host = localhost
user = debian-sys-maint
password = NEWPASSWORD
socket = /var/run/mysqld/mysqld.sock
Step 5. Restart MySQL Server.
sudo service mysql restart
Tip! If you ever get locked out of Root, you can use the debian-sys-maint user to reset your root account.
Lead~Robot