Home  >  Article  >  Database  >  Mysql5.7 quick method to change root password

Mysql5.7 quick method to change root password

PHPz
PHPzOriginal
2017-03-12 14:38:511313browse

mysql Changing the password of the administrator root is a very common problem. There are many tutorials on the Internet. However, the new version of MYSQL5.7 can use the previous tutorials. After some exploration, the editor finally solved it. I found a way to modify it and share it with everyone here.

Version update, the password field in the original user has been changed to authentication_string

Version update. Because of this, many online tutorials are no longer applicable, and even the official website documents cannot be operated smoothly.

If MySQL is running, kill it first:

killall -TERM mysqld。

Run

mysqld_safe --skip-grant-tables &

If you don’t want to be connected remotely at this time:

mysqld_safe --skip-grant-tables --skip-networking &

Use mysql Connect to server

Change password:

update mysql.user set authentication_string=password('123qwe') where user='root' and Host = 'localhost';

*A special reminder is that there is no Password field in the user table under the new version of mysql database

Instead, the encrypted user password is stored in the authentication_string field

mysql> flush privileges;
mysql> quit;

Modification completed. Restart


killall -TERM mysqld。
mysqld_safe &

Then mysql can be connected

But the operation seems to be incomplete at this time, and alter user is required...

alter user 'root'@'localhost' identified by '123';

Internet articles say that Jiang Zi can also be used:

set password for 'root'@'localhost'=password('123');
cp mysql.server /etc/init.d/mysql
chmod +x /etc/init.d/mysql
chkconfig --add mysql

The above is the detailed content of Mysql5.7 quick method to change root password. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn