百分百源码网-让建站变得如此简单! 登录 注册 签到领金币!

主页 | 如何升级VIP | TAG标签

当前位置: 主页>网站教程>数据库> 解决Mysql报错:PHP Warning: mysql_connect(): mysqlnd cannot
分享文章到:

解决Mysql报错:PHP Warning: mysql_connect(): mysqlnd cannot

发布时间:01/15 来源: 浏览: 关键词:
本文章为各位介绍解决Mysql报错:PHP Warning: mysql_connect(): mysqlnd cannot connect to MySQL 4.1+ using the old insecure authentication方法,希望例子能够帮助到各位。

最近我更新了PHP版本,使用mysql_connect()函数会报错:

 

PHP Warning:  mysql_connect(): mysqlnd cannot connect to MySQL 4.1+ using the old insecure authentication. Please use an administration tool to reset your password with the command SET PASSWORD = PASSWORD('your_existing_password'). This will store a new, and more secure, hash value in mysql.user. If this user is used in other scripts executed by PHP 5.2 or earlier you might need to remove the old-passwords flag from your my.cnf file in /root/test.php on line 3

 

原因:

 

MySQL 5.0 为了和4.1之前的版本兼容,用户密码(mysql数据库的user表password字段)保存的是密码的16位hash值,而PHP5.3后的 mysql驱动使用41位的密码hash值进行用户验证,所以需要让mysql中保存用户密码的41位hash值,但配置文件中 old_passwords=1的话,password()函数只能返回16位hash值。

 

解决办法如下:

SET old_passwords = 0;

UPDATE mysql.user SET PASSWORD = PASSWORD( 'phpddt.com' ) WHERE User = 'root' LIMIT 1 ;

SELECT LENGTH( PASSWORD ) FROM mysql.user WHERE User = 'root';

FLUSH PRIVILEGES ;

打赏

打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,你说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

百分百源码网 建议打赏1~10元,土豪随意,感谢您的阅读!

共有18人阅读,期待你的评论!发表评论
昵称: 网址: 验证码: 点击我更换图片
最新评论

本文标签

广告赞助

能出一分力是一分吧!

订阅获得更多模板

本文标签

广告赞助

订阅获得更多模板