MySQL can be used to change the ROOT password.
Method 1: use the set password command
Use the following command on the mysql command line interface:
1 MySQL-u root2 mysql> set password for 'root' @ 'localhost' = PASSWORD ('newpass ');
Method 2: Use mysqladmin
Go to the mysql installation directory and find mysqladmin.
Mysqladmin-u root password "newpass"
If the root user has set a password, use the following method:
Mysqladmin-u root password oldpass "newpass"
Method 3: Use UPDATE to directly edit the user table
1 mysql-u root2 mysql> use mysql; 3 mysql> UPDATE user SET Password = PASSWORD ('newpass') WHERE user = 'root'; 4 mysql> flush privileges;
When the root password is lost
1 mysqld_safe -- skip-grant-tables & 2 mysql-u root mysql3 mysql> UPDATE user SET password = PASSWORD ("new password") WHERE user = 'root '; 4 mysql> flush privileges;