Mysqlnd cannot connect to MySQL 4.1+ using the old insecure authentication

Source: Internet
Author: User

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 ());
}
?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.