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

来源:meishanweb     Time:2016-07-09     点击:1244次

mysqlnd是个好东西。不仅可以提高与mysql数据库通信的效率,而且也可以方便的设置一些超时。如,连接超时,查询超时。
但是,使用mysqlnd的时候,有个地方需要注意。就是服务端的密码格式不能使用旧的16位的存储格式,而要使用新的41位的存储格式。
如果,服务端的密码格式是16位,那么就会报错。信息如下:
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

进入mysql界面输入以下命令

UPDATE mysql.user SET Password = PASSWORD(\\\'8550246\\\') WHERE user = \\\'newpzycms\\\';

select user,length(password) from mysql.user WHERE User=\\\'newpzycms\\\';

FLUSH PRIVILEGES;

下一篇:####   上一篇:####