Warning:mysql_connect () [Function.mysql-connect]: Premature end of data (mysqlnd_wireprotocol.c:554) in path/to/the/ file/where/connection/script/is/written/
Warning:mysql_connect () [Function.mysql-connect]: OK packet 1 bytes shorter than expected in Path/to/the/file/where/conn ection/script/is/written/
Warning:mysql_connect () [Function.mysql-connect]: Mysqlnd cannot connect to MySQL 4.1+ using the old insecure authenticat Ion. Please use a administration tool to reset your password with the command SET password = password (' Your_existing_password ' ). This would 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 path/to/the/file/where/connection/script/is/written/
1. Change the MySQL to does to use Old_passwords
It seems that even MySQL 5.x versions still default to the old password hashes. You are need to change this in ' my.cnf ' (e.g./etc/my.cnf): Remove or comment out of the line that says
Old_passwords = 1
//
Old_passwords = 1 to 16-bit
So here we go.
/
/set old_passwords = 0;
So that the length of the new password becomes 41 bits
Restart MySQL. If you don ' t, MySQL would keep using the old password format, which'll mean that you cannot upgrade the passwords using T He builtin PASSWORD () hashing function. Can test this by running:
The specific reason I still not very clear, with old password length related? Record them first and study them later. The workaround is as follows:
| The code is as follows |
Copy Code |
SET old_passwords = 0; UPDATE mysql.user SET PASSWORD = PASSWORD (' www.chajian8.com ') WHERE user = ' chajian8 ' LIMIT 1; SELECT LENGTH (PASSWORD) from mysql.user WHERE user = ' chajian8 '; FLUSH privileges; |
PHP-attached MySQL test code:
| The code is as follows |
Copy Code |
<?php $con = mysql_connect ("192.168.3.240:3306", "Chajian8", www.111cn.net); if (! $con) { Die (' Could not connect: '. Mysql_error ()); } ?> |