mysql5.7 multi-instance reset password

mysql5.7 non-multi-instance reset password

Execute linux command after killing mysql

mysqld_safe --skip-grant-tables &

You can directly skip the password to enter mysql

 

 

[root@localhost 3306]# mysqld_safe --defaults-file=/data/3306/my.cnf --skip-grant-tables &

enter mysql without password

[root@localhost 3306]# mysql -S /data/3306/mysql.sock

query password

mysql> select user,host,authentication_string from mysql.user\G;

*************************** 1. row ***************************

                 user: root

                 host: localhost

authentication_string: *2A032F7C5BA932872F0F045E0CF6B53CF702F2C5

*************************** 2. row ***************************

                 user: mysql.sys

                 host: localhost

authentication_string: *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE

2 rows in set (0.00 sec)

reset Password

mysql> update mysql.user set authentication_string=password("123456") where user='root' and host='localhost';

Query OK, 1 row affected, 1 warning (0.00 sec)

Rows matched: 1  Changed: 1  Warnings: 1

refresh exit

mysql> flush privileges;

Query OK, 0 rows affected (0.00 sec)

mysql> exit

Bye

 

Stop multi-instance and restart

[root@localhost 3306]# mysqladmin -uroot -p123456 -S /data/3306/mysql.sock shutdown  

[root@localhost 3306]# ./mysql start

Starting MySQL

 

 

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326573372&siteId=291194637