Reset root password for MySQL

You can view the MySQL root password in the file /root/.my.cnf.

# cat /root/.my.cnf 
[client]
pass="sdd568c~M"
user=root

Want to reset the root password for MySQL? Follow the below steps.

1. Stop mysql

2. Create a text file(for eg: /home/mysql-init) and place the following statements in it. Replace the password with the password that you want to use.

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

3. Execute the following command

mysqld_safe --init-file=/home/mysql-init &

4. Remove /home/mysql-init, kill mysql and start mysql.

Other methods may be found here.

Note : You may try other methods as recommended by the control panel [if installed] first.