AWS Debian Password Reset

How to reset the Debian Maintenance password.

We took security precautions, and built ALL of our Ubuntu Linux images using the MySQL secure install script. This limits external access to the MySQL server from localhost only; however, even though we dynamically set the password at EC2 first creation, you may want or need to change it, or you may be locked out of the root account.

Reset Instructions

Before you begin, copy the existing password in the file, and make a full AMI image backup if possible.

Step 1. It is easiest to proceed from Ubuntu CLI. Connect via SSH and issue the following:

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 5.7

UPDATE mysql.user

SET authentication_string = PASSWORD('TO_NEW_PASSWORD'), password_expired = 'N' WHERE User = 'debian-sys-maint' AND Host = 'localhost';



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
host = localhost
user = debian-sys-maint
password = NEWPASSWORD
socket = /var/run/mysqld/mysqld.sock

Step 5. Restart MySQL Server.

sudo service mysql restart

That’s it! Contact support if you have any questions.