MySQL PHP 不兼容 [英] MySQL PHP incompatibility

查看:29
本文介绍了MySQL PHP 不兼容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在本地运行 WAMP,但连接到远程 MySQL 数据库.PHP本地版本为最新的5.3.0.

I'm running WAMP locally, but connecting to a remote MySQL database. The local version of PHP is the latest 5.3.0.

远程数据库之一,版本 5.0.45 工作正常.但是,我尝试连接的另一个远程数据库(版本 5.0.22)在死之前抛出以下错误:

One of the remote databases, being version 5.0.45 works fine. However, the other remote database I'm trying to connect to, which is version 5.0.22 throws the following error before dying:

警告:mysql_connect() [function.mysql-connect]:OK 数据包比预期短 6 个字节.PID=5880 in ...

Warning: mysql_connect() [function.mysql-connect]: OK packet 6 bytes shorter than expected. PID=5880 in ...

警告:mysql_connect() [function.mysql-connect]:mysqlnd 无法连接到 MySQL 4.1+,使用旧的身份验证...

Warning: mysql_connect() [function.mysql-connect]: mysqlnd cannot connect to MySQL 4.1+ using old authentication in ...

WTF?

更新:

恢复到 PHP 5.2.*,即任何低于 5.3.0 的版本都可以完全解决问题.只要我运行的不是 5.3.0,我就可以连接到两个数据库.我不确定这种奇怪的解释是什么.

Reverting to PHP 5.2.* i.e. anything lower than 5.3.0 resolves the problem completely. As long as I am not running 5.3.0 I can connect to both databases. I'm not sure what the explanation is for this weirdness.

推荐答案

您使用的 MySQL 帐户可能有一个旧的 16 个字符长的密码(哈希).
您可以使用 MySQL 客户端(如 HeidiSQL、MySQL 控制台客户端或任何其他客户端)和有权访问 mysql.user 表的帐户进行测试.如果密码字段包含 16 个字符,则它是旧密码,mysqlnd 无法使用它连接到 MySQL 服务器.
您可以使用

The MySQL account you're using probably has an old 16 character long password (hash).
You can test that with a MySQL client (like HeidiSQL, the MySQL console client or any other client) and an account that has access to the mysql.user table. If the Password field contains 16 chars it's an old password and mysqlnd cannot use it to connect to the MySQL server.
You can set a new password for that user with

SET PASSWORD FOR 'username'@'hostmask' = PASSWORD('thepassword')

dev_mysql_set_password


您还应该检查服务器是否设置为 使用/默认创建旧密码.

edit2:
请运行查询

edit2:
Please run the query

SELECT
  Length(`Password`),
  Substring(`Password`, 1, 1)
FROM
  `mysql`.`user`
WHERE
  `user`='username'

在 5.0.22 服务器上(失败"的那个).将 username 替换为您在 mysql_connect() 中使用的帐户.
返回什么?

on the 5.0.22 server (the one that's "failing"). Replace username by the account you're using in mysql_connect().
What does that return?

这篇关于MySQL PHP 不兼容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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