MySQL forget password of root

stop mysql and modify my.cnf

service mysql stop

add below to my.cnf

[mysqld]
skip-grant-tables

reset password of user root

mysql
USE mysql;
UPDATE user SET Password=password('your-new-password') WHERE User='root';
flush privileges;
quit;

modify my.cnf again

remove below from [mysqld]

skip-grant-tables

restart mysql

service mysql restart