Mysql 5.7 Modifying root Password Tutorial

  • 2021-11-13 18:31:45
  • OfStack

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

Because of the version update, many 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 time: mysqld_safe �skip-grant-tables �skip-networking &

Connect 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 mysql database

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


mysql> flush privileges;
mysql> quit;

The revision is complete. Restart


killall -TERM mysqld . 
mysqld_safe &

Then mysql can be connected

But at this time, the operation seems to be incomplete, and alter user …


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

The net text says that sauce purple 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

Summarize


Related articles: