zl程序教程

您现在的位置是:首页 >  数据库

当前栏目

mysql_connect():Connectionusingold(pre-4.1.1)authenticationprotocolrefused

mysql connect 4.1 Pre
2023-06-13 09:15:24 时间

做了一下mysql升级,开发机上mysql升级到5.6版本,结果连接一些低版本的mysql服务器报出如下异常:
Warning:mysql_connect():Connectionusingold(pre-4.1.1)authenticationprotocolrefused(clientoption"secure_auth"enabled)

异常原因在于服务器端的密码管理协议陈旧,使用的是旧有的用户密码格式存储;但是客户端升级之后采用了新的密码格式。mysql5.6版本遇到这种不一致的情况就会拒绝连接。

详见mysql手册“ServerCommandOptions”一节中“--secure-auth"选项的说明:http://dev.mysql.com/doc/refman/5.6/en/server-options.html#option_mysqld_secure-auth


解决方法有如下三种:

1、服务器端升级启用secure_auth选项;

2、客户端连接时off掉secure_auth,即连接时加上--secure_auth=off,如:mysql-p10.51.1.11-P3308-uroot--secure_auth=off

3、找到对应的mysql用户把密码改为新的加密方式,PASSWORD(‘yourpassword"),如:

复制代码代码如下:
SETPASSWORDFORroot=PASSWORD("123456");

对于方法二,使用在程序做相应mysql配置即可,以php为例,在php.ini中设置secure_auth=off