报错信息:Error No. 1251 client does not support authentication protocol requested by server;consider upgrading Mysql client
主要原因
主要是由于mysql8以前的加密规则与mysql8以后的存在差异
解决方法
-
确认mysql服务已启动
[root@influxdb252 ~]# systemctl status mysqld
如果没有启动,先启动。否则,跳过启动进入2。
启动mysql服务:
[root@influxdb252 ~]# systemctl start mysqld [root@influxdb252 ~]# systemctl enable mysqld [root@influxdb252 ~]# systemctl status mysqld
确认mysql服务已启动
-
登录mysql -u root -pPassword(第一次登录没有密码,直接按回车过)!
[root@influxdb252 ~]# mysql -u root -pPassword mysql: [Warning] Using a password on the command line interface can be insecure. Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1423 Server version: 8.0.19 MySQL Community Server - GPLCopyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql>
-
查看用户信息
mysql> select host,user,plugin,authentication_string from mysql.user;
可 以 发 现 r o o t 那 里 的 密 码 与 其 他 的 不 同 \color{red}{可以发现 root 那里的密码与其他的不同} 可以发现root那里的密码与其他的不同 -
修改用户密码(说明:修改后密码可以与原密码保持一致)
mysql> ALTER user root IDENTIFIED WITH mysql_native_password BY 'Password';
-
再次查看用户信息,root密码显示正常了
mysql> select host,user,plugin,authentication_string from mysql.user; +-----------+------------------+-----------------------+------------------------------------------------------------------------+ | host | user | plugin | authentication_string | +-----------+------------------+-----------------------+------------------------------------------------------------------------+ | % | larry | mysql_native_password | *4FE78770B27294B5EF3206556095531B90465771 | | % | myadmin | mysql_native_password | *4A0173621A97B6BA2FE81B6CE76DED94B6FE0B3F | | % | root | mysql_native_password | *83A86A028696B5BC755E0BF5FDB1B2D17AD20C1C | | localhost | mysql.infoschema | caching_sha2_password | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED | | localhost | mysql.session | caching_sha2_password | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED | | localhost | mysql.sys | caching_sha2_password | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED | +-----------+------------------+-----------------------+------------------------------------------------------------------------+ 6 rows in set (0.00 sec)
重新使用SQLyog连接mysql数据库,连接成功
如果仍然失败,刷新下数据库
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)mysql>