It is very frustrating when you can not remember your mysql password, but don’t panic there is a quick way to reset it and it only takes one minute.
This should work on CentOS 6 and 7 and RedHat distributions.
As root run the following.
#service mysqld stop #mysqld_safe --skip-grant-tables #mysql --user=root mysql
mysql> update user set Password=PASSWORD('your new password') where user='root'; mysql> flush privileges; mysql> exit
All done now you can login as root
mysql -u root -p