关于mysql的secure_auth

来源:互联网 发布:深圳房产成交数据 编辑:程序博客网 时间:2024/05/23 13:03

最近做服务器部署,服务器mysql的版本是5.5.37,而客户端用的mysql库是5.6.15,结果就是死活连不上,开始以为是云服务器之间的路由不通。
不过经过核实之后,和链路无关。
然后在本地调试。输出连接失败信息如下:
mysql_connect(): Connection using old (pre-4.1.1) authentication protocol refused (client option 'secure_auth' enabled)

mysql官网给的说明

 --secure-auth

Command-Line Format--secure-authOption-File Formatsecure-authSystem Variable Namesecure_authVariable ScopeGlobalDynamic VariableYes Permitted Values (<= 5.6.4)TypebooleanDefaultOFF Permitted Values (>= 5.6.5)TypebooleanDefaultON

This option causes the server to block connections by clients that attempt to use accounts that have passwords stored in the old (pre-4.1) format. Use it to prevent all use of passwords employing the old format (and hence insecure communication over the network). Before MySQL 5.6.5, this option is disabled by default. As of MySQL 5.6.5, it is enabled by default; to disable it, use --skip-secure-auth.

在这2个版本之间,secure-auth选项默认值有改变,解决方法:

1、服务器这边,在my.cnf中加上

secure-auth=1

重启 service mysqld start

2、客户端这边,mysql_options(mysql,MYSQL_SECURE_AUTH,(my_bool*)0);


建议采用方案1。


参考

http://blog.csdn.net/zuyi532/article/details/10148259

0 0
原创粉丝点击