Mysql 错误:2049的解决

来源:互联网 发布:会员返利系统源码 编辑:程序博客网 时间:2024/05/22 17:08
在做mysql客户端的时候,发现一个问题:我的开发机的mysql版本是5.6.×的,而目标机(mysql server运行的机器)mysql server的版本是5.0.×,我用msql connector/c++ 1.1.16的版本连接服务器,出现了错误:

Error: 2049 (CR_SECURE_AUTH)

Message: Connection using old (pre-4.1.1) authentication protocol refused (client option 'secure_auth' enabled)

消息:拒绝使用旧鉴定协议(早于4.1.1)的连接(开启了客户端'secure_auth'选项)。

因为本人不能更改服务器用户和密码以及密码的加密方式以及服务的mysql的启动参数,在客户端做如下连接:

sql::Driver * driver = get_driver_instance();
sql::ConnectOptionsMap connectionProperties;
connectionProperties["hostName"] = “tcp://192.168.1.20:3306”;
connectionProperties["userName"] = "root";
connectionProperties["password"] = "123456";
connectionProperties["useLegacyAuth"] = true;
sql::Connection * con = driver->connect(connectionProperties);

OK,就这样连接上,必须增加connectionProperties["useLegacyAuth"] = true;这行代码。

当然还有其他的很多方法。我的环境是不能修改服务器的配置。

0 0
原创粉丝点击