【1】sudo vim /etc/mysql/debian.cnf
显示
# Automatically generated for Debian scripts. DO NOT TOUCH!
[client]
host = localhost
user = debian-sys-maint
password = yXFCM3LmQ5wZlcKU
socket = /var/run/mysqld/mysqld.sock
[mysql_upgrade]
host = localhost
user = debian-sys-maint
password = yXFCM3LmQ5wZlcKU
socket = /var/run/mysqld/mysqld.sock
-------------------------------------------------------------------------------------------------------------------------------------------
【2】用debian-sys-maint进入mysql
mysql -u debian-sys-maint -p
password = yXFCM3LmQ5wZlcKU
use mysql
select * from user
select host,user,password_expired,password_last_changed,password_lifetime,account_locked from user;
【3】过滤查看用户信息,我的是因为plugin=auth_socket 问题
select host,user,plugin,authentication_string,password_last_changed,password_lifetime from user;
+-----------+------------------+-----------------------+-------------------------------------------+
| host | user | plugin | authentication_string |
+-----------+------------------+-----------------------+-------------------------------------------+
| localhost | root | auth_socket | *DF4DD04B3437D57619CDDFDD68DF49E2FDCDB2A3 |
| localhost | mysql.session | mysql_native_password | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE |
| localhost | mysql.sys | mysql_native_password | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE |
| localhost | debian-sys-maint | mysql_native_password | *E635E132EF9AD03B99F30035D1F6ECBBFAB0F089 |
| % | root | mysql_native_password | *DF4DD04B3437D57619CDDFDD68DF49E2FDCDB2A3 |
+-----------+------------------+-----------------------+-------------------------------------------+
【4】将首条root的plugin个in更新
update user set plugin="mysql_native_password" where plugin="auth_socket";
mysql> select host,user,plugin,authentication_string from user;
+-----------+------------------+-----------------------+-------------------------------------------+
| host | user | plugin | authentication_string |
+-----------+------------------+-----------------------+-------------------------------------------+
| localhost | root | mysql_native_password | *DF4DD04B3437D57619CDDFDD68DF49E2FDCDB2A3 |
| localhost | mysql.session | mysql_native_password | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE |
| localhost | mysql.sys | mysql_native_password | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE |
| localhost | debian-sys-maint | mysql_native_password | *E635E132EF9AD03B99F30035D1F6ECBBFAB0F089 |
| % | root | mysql_native_password | *DF4DD04B3437D57619CDDFDD68DF49E2FDCDB2A3 |
+-----------+------------------+-----------------------+-------------------------------------------+
5 rows in set (0.00 sec)
[5]退出,重启,解决问题
exit
sudo service mysql restart
网友评论