mysql5.7非多实例重置密码
杀掉mysql后执行linux命令
mysqld_safe --skip-grant-tables &
就可以直接跳过密码进入mysql
[root@localhost 3306]# mysqld_safe --defaults-file=/data/3306/my.cnf --skip-grant-tables &
无密码进入mysql
[root@localhost 3306]# mysql -S /data/3306/mysql.sock
查询密码
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)
重置密码
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
刷新退出
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> exit
Bye
停止多实例并重新启动
[root@localhost 3306]# mysqladmin -uroot -p123456 -S /data/3306/mysql.sock shutdown
[root@localhost 3306]# ./mysql start
Starting MySQL