Reset the MySQL root password.
Jeff Walters February 11th, 2007
A little while ago I inherited an old Plesk server at my workplace. Of course, nobody knew the root password. So, I had to call the hosting company who housed our dedicated server and get the root password for the box. Unfortunately, nobody knew what the MySQL root password was either. Luckily I discovered there is a way to reset this password.
Following are the steps to reset the Mysql password in Plesk:
1) Login to the Server and load MySQL with the ’skip-grant-tables’ in /etc/my.cnf like below. Your file will most likely look different.
[mysqld]
default-character-set=latin1
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
set-variable=max_connections=500
skip-grant-tables
2) Log on the MySQL server and set an empty password for root.
root@support root]# mysql
mysql>FLUSH PRIVILEGES;
mysql>GRANT ALL PRIVILEGES ON *.* TO root@localhost IDENTIFIED BY ‘new password’ WITH GRANT OPTION;
mysql>FLUSH PRIVILEGES;
mysql>\q
3) Comment out or remove string ’skip-grant-tables’ like below.
[mysqld]
default-character-set=latin1
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
set-variable=max_connections=500
#skip-grant-tables
4) Then restart mysqld service with command
/sbin/service mysqld restart
That’s it. Simple when you know how.
Jeff