我收到以下错误:
Database connection failed: 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 yourmy.cnf
file
我在本地机器上使用 PHP 5.3.8 和 MySQL 5.5.16,而我的主机(媒体库)正在运行 PHP 5.3 MySQL 5.0.51a。实时服务器上的版本比我机器上的版本旧。
如何修复此错误并从本地计算机连接到 MySQL?
我知道有与此类似的帖子,但我已经尝试了所有帖子,但没有一个有效。
最佳答案
- 删除或评论 my.cnf 中的 old_passwords = 1
重启 MySQL。如果您不这样做,MySQL 将继续使用旧密码格式,这意味着您无法使用内置的 PASSWORD() 散列函数升级密码。
旧密码哈希是 16 个字符,新密码哈希是 41 个字符。
连接到数据库,并运行以下查询:
SELECT user, Length(`Password`) FROM `mysql`.`user`;
这将显示哪些密码采用旧格式,例如:
+----------+--------------------+ | user | Length(`Password`) | +----------+--------------------+ | root | 41 | | root | 16 | | user2 | 16 | | user2 | 16 | +----------+--------------------+
Notice here that each user can have multiple rows (one for each different host specification).
To update the password for each user, run the following:
UPDATE mysql.user SET Password = PASSWORD('password') WHERE user = 'username';
最后,刷新权限:
FLUSH PRIVILEGES;
来源:How to fix "mysqlnd cannot connect to MySQL 4.1+ using old authentication" on PHP5.3
关于php - 错误 : mysqlnd cannot connect to MySQL 4. 1+ 使用旧的不安全身份验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8831183/