PHP 5.4 PDO无法使用旧的不安全身份验证连接到MySQL 4.1+ [英] PHP 5.4 PDO could not connect to MySQL 4.1+ using the old insecure authentication

查看:120
本文介绍了PHP 5.4 PDO无法使用旧的不安全身份验证连接到MySQL 4.1+的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道有很多类似的问题,实际上我已经阅读了全部(9).

I know there are a tonne of similar questions, in fact I've read all (9) of them.

但是,它们都不能解决我的问题.

However, none of them solve my problem.

我有一个共享主机软件包(最低要求).我的软件包中包括域名,以及托管MySQL服务器的单独IP地址.为了进行开发,我在PHP 5.4的开发服务器上使用了http://localhost/,在托管包中使用的是MySQL服务器.

I have a shared-hosting package (the minimum). What's included in my package is the domain name, and a separate IP address where the MySQL server is hosted. For development, I'm using http://localhost/ with PHP 5.4's development server, and I'm using the MySQL server I get in my hosting package.

该问题仅在我的PC上出现,因为我已经安装了PHP 5.4,但是我的Web主机已经安装了PHP 5.2.17,并且不会升级. MySQL服务器在MySQL 5.1.50上.

The problem arises only on my PC, because I have installed PHP 5.4, but my web host has installed PHP 5.2.17 and won't upgrade. The MySQL server is on MySQL 5.1.50.

幸运的是,phpMyAdmin具有内置的更改密码"功能.

phpMyAdmin中有两个用于更改密码的哈希选项:

There are two hashing options in phpMyAdmin for changing a password:

  • MySQL 4.1+
  • 与MySQL 4.0兼容

我使用MySQL 4.1+选项更改了密码,并确认更新成功.

I changed the password with the MySQL 4.1+ option, and it confirmed the update was successful.

配置文件已更新. SET PASSWORD = PASSWORD( '***' )

但是,当我执行此查询时:

However, when I perform this query:

SELECT @@global.old_passwords, @@session.old_passwords, Length(PASSWORD('abc'));

它告诉我密码长度仍为16.输出:

It tells me the password length is still 16. Output:

1     1     16

因此问题仍然存在.

无法连接到数据库. SQLSTATE [HY000] [2000] mysqlnd无法使用旧的不安全身份验证连接到MySQL 4.1+.请使用管理工具通过命令SET PASSWORD = PASSWORD('your_existing_password')重置密码.这将在mysql.user中存储一个新的,更安全的哈希值.如果此用户在PHP 5.2或更早版本执行的其他脚本中使用过,则可能需要从my.cnf文件中删除old-passwords标志

Could not connect to database. 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

在phpMyAdmin中使用DBO用户登录时,我也尝试过执行以下查询:

I've also tried to do these queries, when logged in with the DBO user in phpMyAdmin:

SET SESSION old_passwords=0; 
[phpMyAdmin reloads to the home screen, but the value remains = 1]

SET GLOBAL old_passwords = 0;
#1227 - Access denied; you need the SUPER privilege for this operation

FLUSH PRIVILEGES;
#1227 - Access denied; you need the RELOAD privilege for this operation

这与设置DBO用户的Web主机菜单中指出的内容相反:

This is contradictory to what is stated in the webhost's menu for setting the DBO user:

数据库所有者
创建新数据库时,需要指定一个数据库所有者(DBO)用户,该用户将具有
管理员对数据库的完全访问权限.

Database Owner
When you create a new database, you need to specify a Database Owner (DBO) User, which will have
full administrator access to the database.

这是我必须处理的Web主机吗?还是可以由我的DBO用户解决?否则可以绕过PHP吗? (因为它适用于PHP 5.2.17,但不适用于PHP 5.4)

Is this something I have to take up with my webhosts? Or can it be solved by my DBO user? Otherwise can this be bypassed in PHP? (since it works with PHP 5.2.17 but not PHP 5.4)

推荐答案

已解决!

尽管SET SESSION old_passwords=0;在phpMyAdmin中不起作用.

SOLVED!

Although the SET SESSION old_passwords=0; wasn't working in phpMyAdmin.

我下载了 MySQL GUI工具,并使用了MySQL查询浏览器在非DBO用户上执行相同的命令:

I downloaded the MySQL GUI Tools and used the MySQL Query Browser to execute the same command on non-DBO user:

SET SESSION old_passwords = 0;

SELECT @@global.old_passwords, @@session.old_passwords, Length(PASSWORD('abc'));

现在返回:

1      0      41

所以我只是更改了密码:

So I simply changed the password:

SET PASSWORD = PASSWORD('my_old_password')

现在,PHP 5.4 PDO通过该用户连接到数据库!

And now PHP 5.4 PDO connects to the database with that user!

这篇关于PHP 5.4 PDO无法使用旧的不安全身份验证连接到MySQL 4.1+的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆