天天看點

mysqlnd cannot connect to MySQL 4.1+ using the old insecure authentication解決辦法

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

如何檢視自己的密碼是否符合要求,so easy。

上面的密碼是舊的16位格式。如果想改成新的41位格式,通過以下指令就可以。

修改完密碼後,還需要在配置檔案中修改下old_passwords選項。把值設定為0。即,

old_passwords=0

然後重新開機mysql。