Home  >  Article  >  Database  >  mysql_connect(): Connection using old (pre-4.1.1) authentica_MySQL

mysql_connect(): Connection using old (pre-4.1.1) authentica_MySQL

WBOY
WBOYOriginal
2016-06-01 13:17:471066browse

做了一下mysql升级,开发机上mysql升级到5.6版本,结果连接一些低版本的mysql服务器报出如下异常:
Warning: mysql_connect(): Connection using old (pre-4.1.1) authentication protocol refused (client option 'secure_auth' enabled)

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

详见mysql手册“Server Command Options”一节中“--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(‘your password'),如:
SET PASSWORD FOR root=PASSWORD('123456');

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

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn