service mysql stopmysqld_safe --skip-grant-tables &
mysql -u root
mysql> use mysql;
Check if there is a record for root
mysql> select * from user where User='root';
If it returns no result, create the user again
mysql> insert into user (Host, User, Password) values ('localhost','root','');
mysql> update user set Select_priv='Y',Insert_priv='Y',Update_priv='Y',Delete_priv='Y',Create_priv='Y',Drop_priv='Y',Reload_priv='Y',Shutdown_priv='Y',Process_priv='Y',File_priv='Y',Grant_priv='Y',References_priv='Y',Index_priv='Y',Alter_priv='Y',Show_db_priv='Y',Super_priv='Y',Create_tmp_table_priv='Y',Lock_tables_priv='Y',Execute_priv='Y',Repl_slave_priv='Y',Repl_client_priv='Y',Create_view_priv='Y',Show_view_priv='Y',Create_routine_priv='Y',Alter_routine_priv='Y',Create_user_priv='Y' where user='root';
mysql> update user set Password=PASSWORD('new-password') where user='root';
mysql> flush privileges;
Then quit the database console, kill the mysqld_safe daemon and start the standard mysql daemon again:
mysql> quit
killall mysqld_safe
service mysqld start