加入收藏 | 设为首页 | 会员中心 | 我要投稿 北几岛 (https://www.beijidao.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

PHP的“数据提前结束”错误

发布时间:2021-07-06 05:19:08 所属栏目:大数据 来源: https://www.jb51.cc
导读:我刚刚开始在一个PHP项目中使用WAMP,我得到了与这行代码相关的下一个错误: $link=MysqL_connect("localhost","myuser","mypas"); 我读到我必须使用旧密码再次执行SET PASSWORD,但重启所有服务后仍然无效.我正在使用PHP 5.3.4和MysqL 5.1.53任何帮助?谢谢 W

我刚刚开始在一个PHP项目中使用WAMP,我得到了与这行代码相关的下一个错误:

$link=MysqL_connect("localhost","myuser","mypas");

我读到我必须使用旧密码再次执行SET PASSWORD,但重启所有服务后仍然无效.我正在使用PHP 5.3.4和MysqL 5.1.53任何帮助?谢谢

Warning: MysqL_connect() [function.MysqL-connect]: Premature end of data (MysqLnd_wireprotocol.c:554) in C:wampwwwCDEincludesbaseDatos.PHP on line 5 
Call Stack 
1 0.0002 667312 {main}( ) ..index.PHP:0 
2 0.0008 682416 include( 'C:wampwwwCDEincludesseguridad.PHP' ) ..index.PHP:2 
3 0.0010 690984 include( 'C:wampwwwCDEincludesbaseDatos.PHP' ) ..seguridad.PHP:2 
4 0.0014 692368 MysqL_connect ( ) ..baseDatos.PHP:5 

( ! ) Warning: MysqL_connect() [function.MysqL-connect]: OK packet 1 bytes shorter than expected in C:wampwwwCDEincludesbaseDatos.PHP on line 5 
Call Stack 
1 0.0002 667312 {main}( ) ..index.PHP:0 
2 0.0008 682416 include( 'C:wampwwwCDEincludesseguridad.PHP' ) ..index.PHP:2 
3 0.0010 690984 include( 'C:wampwwwCDEincludesbaseDatos.PHP' ) ..seguridad.PHP:2 
4 0.0014 692368 MysqL_connect ( ) ..baseDatos.PHP:5 

( ! ) Warning: MysqL_connect() [function.MysqL-connect]: 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 in C:wampwwwCDEincludesbaseDatos.PHP on line 5 
Call Stack 
1 0.0002 667312 {main}( ) ..index.PHP:0 
2 0.0008 682416 include( 'C:wampwwwCDEincludesseguridad.PHP' ) ..index.PHP:2 
3 0.0010 690984 include( 'C:wampwwwCDEincludesbaseDatos.PHP' ) ..seguridad.PHP:2 
4 0.0014 692368 MysqL_connect ( ) ..baseDatos.PHP:5 

解决方法:

我有同样的问题,并使用这样的UPDATE查询修复它:

UPDATE MysqL.user SET Password = PASSWORD('newpwd') WHERE Host = 'some_host' AND User = 'some_user';

不知道为什么但SET密码不起作用.

为了确保问题是我认为你应该在MysqL数据库上执行此查询的问题:

SELECT
`user`.`Password`
FROM
`user`
WHERE
`user`.`User` = 'youruser' AND
`user`.`Host` = 'yourhost'

如果密码不以*开头,问题是您仍然有旧的标识

编辑_这是一个PHP函数,用于为MysqL创建有效密码(取自here):

function MysqL_41_password($in)
{
$p=sha1($in,true);
$p=sha1($p);
return "*".strtoupper($p);
}

您可以手动设置密码:

//newpwd is the passowr dgenerated in PHP
UPDATE MysqL.user SET Password = 'newpwd' WHERE Host = 'some_host' AND User = 'some_user';
FLUSH PRIVILEGES;

(编辑:北几岛)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读