我有两个环境:
两者都连接到远程MySQL 5.5.24
服务器。允许远程连接。
我将所有mysql函数替换为mysqli
。在生产中它连接OK,但在开发中遇到以下错误:
Premature end of data (mysqlnd_wireprotocol.c:553)
OK packet 1 bytes shorter than expected
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
MySQL为5.5.24而非4.1 ,old_passwords
设置为Off
这一奇怪的事情。我甚至更改了用户的密码(从主机面板,我没有管理员权限在MySQL本身做到这一点)。
我甚至尝试使用较新版本的PHP(5.4.15),问题仍然存在。
我读到的所有引用都指向过时的MySQL服务器(不是这种情况),old_password问题(再次不是这种情况,因为它在生产时连接正常)。
更新:
旧的mysql
函数既不起作用也不起作用。在将mysql更改为mysqli之前,我使用的是PHP 5.2。*版本,并且它有效。所以我几乎可以肯定问题与捆绑的mysqlnd
有关。
答案 0 :(得分:0)
如果您有MySQLND,则无法在任何情况下使用old_passwords进行身份验证。 这是MySQLND的缺点,可能是它未被采用的主要原因,并且很长一段时间不会被主流,特别是共享托管公司采用。
对不起。
万一你想知道为什么会这样: 旧式密码被认为是高度不安全的,因此删除了对它的支持,迫使人们在想要mysqlnd的好处时更新他们的密码。
修正: 更新密码。
SET old_passwords=FALSE;
SET PASSWORD FOR 'User'@'Host'=PASSWORD('yourpassword');
FLUSH Privileges
您还应该将old_passwords = 0添加到my.cnf并重新启动mysql。