How does mysql change the root password?
The root password can be modified in a variety of situations. Details are as follows:
Before setting the root password:
The method of the SET PASSWORD command:
Mysql-u rootmysql > SET PASSWORD FOR 'root'@'localhost' = PASSWORD (' password you want to set')
The method of the mysqladmin command:
Mysqladmin-u root password "password you want to set"
Edit the user table directly by UPDATE:
Mysql-u rootmysql > USE mysql;mysql > UPDATE user SET Password = PASSWORD ('password you want to set') WHERE user = 'root';mysql > FLUSH PRIVILEGES
After setting up root:
The way of mysqladmin:
Mysqladmin-u root password oldpass "the new password you want to set"
Set the root password, but forgot:
Mysqld_safe-- skip-grant-tables&mysql-u root mysqlmysql > UPDATE user SET password = PASSWORD ("the new password you want to set") WHERE user = 'root'; mysql > FLUSH PRIVILEGES
These are the details of various ways for mysql to modify root password. Please pay attention to other related articles for more information.