用MySQL5.7的客户端连接MySQL8.0的服务端竟然报错,不是说好向下兼容吗?

在默认条件下,用MySQL5.7的客户端连接MySQL8.0的服务端竟然报错,不是说好向下兼容吗? WHAT?
报错如下:
[root@node234 ~]# mysql -ushukuinfo -p'123456' -h172.16.1.223
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 2026 (HY000): SSL connection error: protocol version mismatch


究竟是什么情况,我们一探究竟哈。。。   

原由:
MySQL 8.0数据库初始化时默认开启了SSL,之前版本的数据库默认是禁用SSL的。同时,MySQL 5.7之前版本的客户端默认禁用SSL,而MySQL 5.7版本的客户端在数据库端支持SSL的情况下会尝试创建SSL加密连接。所以,MySQL 5.5/5.6版本客户端不使用加密连接MySQL 8.0数据库,连接是成功的;而MySQL 5.7版本客户端使用SSL加密连接MySQL 8.0数据库,连接失败。

综上所述,解决方法有两个:
1.在使用mysql5.7的客户端中禁用ssl功能:
[root@node234 ~]# mysql -ushukuinfo -p'123456' -h172.16.1.223 --skip-ssl
mysql: [Warning] Using a password on the command line interface can be insecure.
WARNING: --ssl is deprecated and will be removed in a future version. Use --ssl-mode instead.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 13
Server version: 8.0.33 MySQL Community Server - GPL

Copyright (c) 2000, 2017, 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.

(shukuinfo@C7-M5.7.18) [(none)]> 

2.在mysql8.0中禁用ssl功能:
vim /etc/my.cnf
添加以下内容 
[mysqld]
skip_ssl

重启服务
systemctl restart mysqld

在安装有MySQL5.7的客户端服务器中,就可以直接连接了MySQL 8.0版本的服务端了:
[root@node234 ~]# mysql -ushukuinfo -p'123456' -h172.16.1.223
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 11
Server version: 8.0.33 MySQL Community Server - GPL

Copyright (c) 2000, 2017, 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.

(shukuinfo@C7-M5.7.18) [(none)]> 

通过以上两种方法,我们就可以愉快的使用MySQL哦。。。

文章看完了,如果觉得本文对您的工作或生活有用,希望分享给你身边的朋友,一起学习,共同进步哈~~~

欢迎关注我的公众号【数库信息技术】,你的关注是我写作的动力源泉

各大平台都可以找到我:
————————————————————————————
公众号:数库信息技术
墨天轮:https://www.modb.pro/u/427810
百家号:https://author.baidu.com/home/1780697309880431
CSDN :https://blog.csdn.net/rscpass
51CTO: https://blog.51cto.com/u_16068254
博客园:https://www.cnblogs.com/shukuinfo
知乎:https://www.zhihu.com/people/shukuinfo
————————————————————————————

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值