Multiple ways to modify password of MySQL

1: excute command SET PASSWORD

MySQL -u root

mysql> SET PASSWORD FOR ‘root’@’localhost’ = PASSWORD(‘newpass’);

 

2:mysqladmin

mysqladmin -u root password “newpass”

You can excute the following command if root password had been set.

mysqladmin -u root password oldpass “newpass”

 

3: UPDATE user table

mysql -u root

mysql> use mysql;

mysql> UPDATE user SET Password = PASSWORD(‘newpass’) WHERE user = ‘root’;

mysql> FLUSH PRIVILEGES;

 

You can also take the following action if root password lost.

mysqld_safe –skip-grant-tables&

mysql -u root mysql

mysql> UPDATE user SET password=PASSWORD(“new password”) WHERE user=’root’;

mysql> FLUSH PRIVILEGES;

Leave a Reply