Home > Database > Mysql Tutorial > How to change the root password sharing in Mysql5.7

How to change the root password sharing in Mysql5.7

PHPz
Release: 2017-04-03 17:31:45
Original
1435 people have browsed it

Mysql Changing the administrator root password 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 found a way to modify it. Here Share it with everyone.

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 to connect to the server

Change password:

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

*One thing to note in particular is that there is no Password field in the user table under the new version of mysql database

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

mysql> flush privileges;
mysql> quit;
Copy after login

modified. 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 you need to alter user...

alter user 'root'@'localhost' identified by '123';
Copy after login

The Internet article said that Jiang Zi can also do it:

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 How to change the root password sharing in Mysql5.7. 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