usemysql;4mysql>updateusersetpassword=passworD("test")wher"/> usemysql;4mysql>updateusersetpassword=passworD("test")wher">
Outside the mysql system, use mysqladmin
1 mysqladmin -u root -p password "test123" 2 Enter password: 【输入原来的密码】
By logging in to the mysql system
1 mysql -uroot -p 2 Enter password: 【输入原来的密码】 3 mysql>use mysql; 4 mysql> update user set password=passworD("test") where user='root'; 5 mysql> exit;
Note: If the version of Mysql is 5.7 and above, replace the update statement as follows:
1 mysql> update user set authentication_string=passworD("test") where user='root';
First get the root permissions of the operating system, and then kill the Mysql service or stop it manually. Here I recommend using manual stop;
1 service mysql stop
Then execute
1 mysqld_safe --skip-grant-tables &
& means running in the background. If it no longer runs in the background, just open another terminal.
Then log in to MySQL and change the password
1 mysql 2 mysql> use mysql; 3 mysql> UPDATE user SET password=password("test123") WHERE user='root'; 4 mysql> exit;
Note: If the version of Mysql is 5.7 or above, the update statement is as follows:
1 mysql> update user set authentication_string=passworD("test") where user='root';
The above is the detailed content of How to change mysql password in Linux system. For more information, please follow other related articles on the PHP Chinese website!