“数据提前结束” PHP 错误
我刚刚开始在 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:\wamp\www\CDE\includes\baseDatos.php on line 5
Call Stack
1 0.0002 667312 {main}( ) ..\index.php:0
2 0.0008 682416 include( 'C:\wamp\www\CDE\includes\seguridad.php' ) ..\index.php:2
3 0.0010 690984 include( 'C:\wamp\www\CDE\includes\baseDatos.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:\wamp\www\CDE\includes\baseDatos.php on line 5
Call Stack
1 0.0002 667312 {main}( ) ..\index.php:0
2 0.0008 682416 include( 'C:\wamp\www\CDE\includes\seguridad.php' ) ..\index.php:2
3 0.0010 690984 include( 'C:\wamp\www\CDE\includes\baseDatos.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:\wamp\www\CDE\includes\baseDatos.php on line 5
Call Stack
1 0.0002 667312 {main}( ) ..\index.php:0
2 0.0008 682416 include( 'C:\wamp\www\CDE\includes\seguridad.php' ) ..\index.php:2
3 0.0010 690984 include( 'C:\wamp\www\CDE\includes\baseDatos.php' ) ..\seguridad.php:2
4 0.0014 692368 mysql_connect ( ) ..\baseDatos.php:5
I've just started using WAMP for a PHP project and I get the next errors related with this line of code:
$link=mysql_connect("localhost","myuser","mypas");
I read that I had to do the SET PASSWORD again with my old password, but it still does not work after restarting all services. I am using PHP 5.3.4 and MySQL 5.1.53 Any help? THANKS
Warning: mysql_connect() [function.mysql-connect]: Premature end of data (mysqlnd_wireprotocol.c:554) in C:\wamp\www\CDE\includes\baseDatos.php on line 5
Call Stack
1 0.0002 667312 {main}( ) ..\index.php:0
2 0.0008 682416 include( 'C:\wamp\www\CDE\includes\seguridad.php' ) ..\index.php:2
3 0.0010 690984 include( 'C:\wamp\www\CDE\includes\baseDatos.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:\wamp\www\CDE\includes\baseDatos.php on line 5
Call Stack
1 0.0002 667312 {main}( ) ..\index.php:0
2 0.0008 682416 include( 'C:\wamp\www\CDE\includes\seguridad.php' ) ..\index.php:2
3 0.0010 690984 include( 'C:\wamp\www\CDE\includes\baseDatos.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:\wamp\www\CDE\includes\baseDatos.php on line 5
Call Stack
1 0.0002 667312 {main}( ) ..\index.php:0
2 0.0008 682416 include( 'C:\wamp\www\CDE\includes\seguridad.php' ) ..\index.php:2
3 0.0010 690984 include( 'C:\wamp\www\CDE\includes\baseDatos.php' ) ..\seguridad.php:2
4 0.0014 692368 mysql_connect ( ) ..\baseDatos.php:5
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
出现上述问题是由于PHP和MySQL版本不兼容造成的。大多数情况下可能发生在远程访问数据库期间。
请检查您的 PHP 和 MySQL 版本。
我的版本是PHP-5.3.6(本地机器)和MySQL 5.1.56(Live DB)。
我的 MySQL 放置在实时域中,我将 PHP 文件保存在本地计算机中。我遇到了同样的密码重置问题。
然后我用旧版本替换我的 XAMPP,它将我的 PHP 版本更改为 5.3.0。现在上述问题已经解决,我可以从本地访问实时数据库。
The above problem occurs because of version in-compatibility between PHP and MySQL. Mostly it may occur during remote access of db.
Kindly check your PHP and MySQL versions.
My versions are PHP-5.3.6 (Local machine) and MySQL 5.1.56 (Live DB).
My MySQL is placed in live domain and I kept my PHP files in local machine. I faced the same password rest problem.
Then I replace my XAMPP with older version it changed my PHP version to 5.3.0. Now the above problem was solved and I am able to access the live db from local.
我遇到了同样的问题,并使用如下更新查询修复了它:
不知道为什么,但设置密码不起作用。
为了确保问题是我认为你应该在 mysql 数据库上执行此查询:
如果密码不以 * 开头,问题是你仍然有旧的加密
编辑 _ 这是一个要创建的 php 函数MYSQL 的有效密码(取自此处):
Thene您可以手动设置密码:
I had the same problem and fixed it using an UPDATE query like this:
Don't know why but SET Password didn't work.
To be sure that the problem is the one i think you should do this query on the mysql database:
if the password doesn't start with a * the problem is that you still have the old encription
EDIT _ Here is a php function to create valid password for MYSQL (taken from here):
Thene you can set the password manually:
如果使用 MySQL 4.1 + 尝试
在 MySQL 命令行
mysql>设置old_passwords = 0;
mysql>为 'user'@'some.host.domain' 设置密码 = PASSWORD('new_pass');
mysql>设置old_passwords = 1;
If using MySQL 4.1 + Try this
At the MySQL Command line
mysql> set old_passwords = 0;
mysql> set password for 'user'@'some.host.domain' = PASSWORD('new_pass');
mysql> set old_passwords = 1;
您正在连接到本地主机表明您可能没有网络问题。
Google 中的首次点击列出了 2 个可能的原因/补救措施。
That you are connecting to localhost suggests that you probably don't have network problems.
First hit in Google lists 2 possible causes/remedies.