MySQL PHP不兼容 [英] MySQL PHP incompatibility

查看:79
本文介绍了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


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

edit:
You should also check if the server is set to use/create old passwords by default.

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天全站免登陆