Mysql 5.7 Modify root password tutorial

  • 2020-12-10 00:54:05
  • OfStack

The password field in user has been changed to authentication_string

Version update, a lot of online tutorials are not applicable, and even the official website documents are not able to operate smoothly.

If MySQL is running, kill it first:


killall -TERM mysqld . 

run


mysqld_safe --skip-grant-tables &

If you do not want to be remotely connected at this point: mysqld_safe -- skip-ES19en-ES20en -- ES21en-ES22en &

Connect to server using mysql

Change password:


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

* One special note is that the Password field is no longer in the user table under the new version of the mysql database

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


mysql> flush privileges;

mysql> quit;

That's it. restart


killall -TERM mysqld . 

mysqld_safe &

Then mysql can connect

But at this point the operation seems not fully functional, alter user...


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

The article says it's ok to use purple sauce:


set password for 'root'@'localhost'=password('123');

cp mysql.server /etc/init.d/mysql

chmod +x /etc/init.d/mysql

chkconfig --add mysql


Related articles: