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

Mysql5.7 quick method to change root password

PHPz
Release: 2017-03-12 14:38:51
Original
1337 people have browsed it

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。
Copy after login

Run

mysqld_safe --skip-grant-tables &
Copy after login

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

mysqld_safe --skip-grant-tables --skip-networking &
Copy after login

Use mysql Connect to server

Change password:

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

*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;
Copy after login

Modification completed. Restart


killall -TERM mysqld。
mysqld_safe &
Copy after login

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';
Copy after login

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
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template