Reset Mysql Root Password

I started a new job where they fired the old server administrator before hiring a new one (very bad idea). Anyway, they didn’t leave the mysql root password behind so I had to reset it.

You will still need root access to the Linux box running the database.  Do the following logged in as root.

Step 1:

Create the following file named “mysql-init” in /root:

UPDATE mysql.user SET Password=PASSWORD('myNEWpassword') WHERE User='root';FLUSH PRIVILEGES;

Note: ensure UPDATE and FLUSH are on their own lines.

Step 2:

Kill mysqld:

killall mysqld

Step 3:

Run your mysql-init:

mysqld_safe --user=mysql --init-file=/root/mysql-init &

Note: Make sure the user is set to your mysql user.

Step 4:

After the server has started successfully, delete your mysql-init for security:

rm /root/mysql-init

Leave Your Response