PHP 5.3 / Mysql 5.5 / FreeBSD
You get the error message:
Warning: mysql_connect() [function.mysql-connect]: Premature end of data (mysqlnd_wireprotocol.c:553) in C:\directorya\directoryb\dbconnect.phpon line 57
Warning: mysql_connect() [function.mysql-connect]: OK packet 1 bytes shorter than expected in C:\directorya\directoryb\dbconnect.php on line 57
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:\xampp\htdocs\admin.php on line 119
cannot connect
In this scenario the PHP version had been upgraded from 5.2.x to 5.3.x. I believe in this version, the mysqlnd (MySQL Native Driver for PHP) requires a 41 byte hash password. If MySQL had been upgraded from previous versions it may well still be a 16 byte password. A password reset will fix the issue (Note: You’ll need to have the relevant permissions to be able to do this)
> use mysql;
> SET password for ‘username’@’%’=PASSWORD(‘password’);
> FLUSH PRIVILEGES
Note: An official note from the PHP5.3 compatibility Manual
The new mysqlnd library necessitates the use of MySQL 4.1’s newer 41-byte password format. Continued use of the old 16-byte passwords will cause mysql_connect() and similar functions to emit the error, “mysqlnd cannot connect to MySQL 4.1+ using old authentication.”