【问题标题】:mysqlnd cannot connect to MySQL 4.1+ using the old insecure authenticationmysqlnd 无法使用旧的不安全身份验证连接到 MySQL 4.1+
【发布时间】:2011-08-12 16:25:08
【问题描述】:

我在从 PHP 5.3.5(WAMP 安装)连接到 MySQL 5.5.8 时遇到问题。我收到以下错误:

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

我已经尝试了所有可以在网络上找到的建议,包括来自 Stack Overflow 的一些建议和这个:http://engin.bzzzt.biz/2010/11/12/php-mysql-insecure-authentication/

我检查了我的设置并且旧密码标志已关闭。我已将密码更新为新密码哈希,并验证哈希在 users 表中是 41 个字符并刷新了权限。出于某种原因,我仍然收到错误消息。有人有什么想法吗?

更新:我正在使用 ZenCart。这是我正在建立连接和引发错误的行:

$this->link = @mysql_connect($zf_host, $zf_user, $zf_password, true) or die (mysql_error());

【问题讨论】:

  • 显示您的连接代码。记得隐藏用户名/密码/主机名。
  • @Marc B - 不幸的是,我认为代码不会有太大帮助。我在继承项目的这个特定实例中使用 ZenCart。我已经用我正在建立连接的行更新了帖子。
  • @Marc B - 您建议的链接与我在原始问题中提到的相同。我已经尝试了那里的建议。
  • D'oh...我需要检查一下我的眼睛...

标签: php mysql


【解决方案1】:

使用有问题的用户与客户端连接到 MySQL,执行以下命令:

SET old_passwords=0;
SET password=PASSWORD('your current password');

【讨论】:

    【解决方案2】:

    想通了!是我的疏忽。显然,在 ZenCart 中有 2 个文件,您必须在其中设置数据库配置。一个用于目录,一个用于管理区域。对我来说没有多大意义,因为它们都连接到同一个数据库。出于安全原因,可能与能够将一个数据库用户用于目录和一个用于管理员有关。我只是设置了一个本地副本并更改了其中一个配置文件而不更改另一个。导致问题的文件仍然指向我的生产数据库。知道它必须是简单的!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-01-21
      • 2010-12-07
      • 2011-09-25
      • 2012-01-18
      • 1970-01-01
      • 2015-03-08
      相关资源
      最近更新 更多