reseting mysql root password [duplicate]

Is there a mysql command to reset the root password?

I am trying

 mysql -p -u root

but I've forgotten the password.

Is there any way to reset the password?


Solution 1:

Check the doc http://dev.mysql.com/doc/refman/5.1/en/resetting-permissions.html

Basically this should be

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

Solution 2:

You can start the mysql-daemon with the argument --skip-grant-tables, then you can login without prompt and alter passwords.

http://dev.mysql.com/doc/refman/5.1/en/set-password.html

Solution 3:

see this

http://dev.mysql.com/doc/refman/5.1/en/resetting-permissions.html