遇到“mysqlnd cannot connect to MySQL 4.1+ using old insecure authentication....”的解決辦法
在安裝phpthink時(shí)報(bào)錯(cuò)
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
原因:使用高版本mysql數(shù)據(jù)庫(kù)導(dǎo)入了低版本數(shù)據(jù)引起的,其中高版本數(shù)據(jù)庫(kù)的password hashes 是41位的hashes,而低版本數(shù)據(jù)庫(kù)的數(shù)據(jù)存儲(chǔ)的root 的password是16位的hashes,需要修改user表的password字段數(shù)據(jù)為41為的hashes。
解決辦法:
use mysql; // 進(jìn)入存儲(chǔ)user表的數(shù)據(jù)庫(kù)
set session old_passwords=0; //修改session使用41位hashes(16為1,41的為0)
select password('root'); //查看你的password函數(shù)是否可以生成41位的hashes
set password for 'root' @'localhost' = password('root'); //使用password函數(shù)修改你的root密碼為41的hashes