How to resetting a forgotten MySQL root password

Here are different ways

if you just need to change your current password

Here is mysql

yourname@yourname: $ (mysql_dir)mysql --user=root --pass mysql
Enter password:

mysql> update user set Passwprd=PASSWORD('new-ps-here') where User='root';
mysql> flush privileges;
mysql> exit

OK, You have nothing. Here is the solution

1.Make sure your mysql service is shutdown
you may use those

1. $ /etc/init.d/mysql stop
2. service mysqld stop
3. $ (mysql_dir)/bin/mysqladmin -u root -p shutdown
  1. Use the Mysql-safe command

    yourname@yourname: $ (mysql_dir)mysql_safe –skip-grant-tables & [1] 6702
    Starting mysqld deamon with databases from /var/lib/mysql

    you can see the new job has started and server is running with the process ID 6702.

    You can login without a password and do what you want.

Have fun ~