检查MySQL服务器require_secure_transport系统变量,如果为ON启用此变量后,服务器仅允许使用TLS/SSL加密的TCP/IP连接。
mysql> show variables like 'require_secure_transport';
+--------------------------+-------+
| Variable_name | Value |
+--------------------------+-------+
| require_secure_transport | OFF |
+--------------------------+-------+
1 row in set (0.01 sec)
修改客户端使用SSL加密连接
方法一:修改my.cnf文件
vim /etc/my.cnf
.....
require_secure_transport=ON
修改好后重启服务
方法二:配置系统环境变量
mysql> set global require_secure_transport=ON;
Query OK, 0 rows affected (0.02 sec)
mysql> show variables like 'require_secure_transport';
+--------------------------+-------+
| Variable_name | Value |
+--------------------------+-------+
| require_secure_transport | ON |
+--------------------------+-------+
1 row in set (0.05 sec)
[root@sztech ~]# mysql -utest -ptest123456
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 1045 (28000): Access denied for user 'test'@'localhost' (using password: YES)
正确登录方式:
[root@sztech ~]# mysql -utest -ptest123456 --ssl-mode=require