Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
694 views
in Technique[技术] by (71.8m points)

mysql - "Premature end of data" error with PHP

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:wampwwwCDEincludesaseDatos.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:wampwwwCDEincludesaseDatos.php' ) ..seguridad.php:2 
4 0.0014 692368 mysql_connect ( ) ..aseDatos.php:5 

( ! ) Warning: mysql_connect() [function.mysql-connect]: OK packet 1 bytes shorter than expected in C:wampwwwCDEincludesaseDatos.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:wampwwwCDEincludesaseDatos.php' ) ..seguridad.php:2 
4 0.0014 692368 mysql_connect ( ) ..aseDatos.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:wampwwwCDEincludesaseDatos.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:wampwwwCDEincludesaseDatos.php' ) ..seguridad.php:2 
4 0.0014 692368 mysql_connect ( ) ..aseDatos.php:5 
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...