首页 > 数据库技术 > 详细

mysqlnd cannot connect to MySQL 4.1+ using the old insecure authentication解决办法

时间:2015-03-20 18:54:34      阅读:321      评论:0      收藏:0      [点我收藏+]

Fatal error: Uncaught exception ‘PDOException’ with message ‘SQLSTATE[HY000] [2000] 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 /home/hailong.xhl/test.php:8

mysqlnd是个好东西。不仅可以提高与mysql数据库通信的效率,而且也可以方便的设置一些超时。如,连接超时,查询超时。
但是,使用mysqlnd的时候,有个地方需要注意。就是服务端的密码格式不能使用旧的16位的存储格式,而要使用新的41位的存储格式

查看自己的密码是否符合要求

mysql> select user,host,length(password) from mysql.user; 
+-----------+-----------+------------------+
| user      | host      | length(password) |
+-----------+-----------+------------------+
| root      | localhost |                0 | 
| demo      | %         |                16| 
| root      | 127.0.0.1 |                0 | | 
| root      | 192.168.% |               16 | 
| 
|

上面的密码是旧的16位格式。如果想改成新的41位格式,通过以下命令就可以


mysql> set old_passwords=0;
mysql> update mysql.user set Password = PASSWORD("demo") where user="demo";
 mysql> select user,length(password) from mysql.user;
+--------------+------------------+
| user         | length(password) |
+--------------+------------------+
| demo         |               41 | 
| demo         |               41 | 
+--------------+------------------+
mysql> flush privileges

修改完密码后,还需要在配置文件中修改下old_passwords选项。把值设置为0

mysqlnd cannot connect to MySQL 4.1+ using the old insecure authentication解决办法

原文:http://dihuo.blog.51cto.com/1657091/1622559

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!