Resolve MYSQLND cannot connect to MySQL 4.1+ using the ' old ' insecure authentication error

Source: Internet
Author: User
Tags mysql database

Mysqlnd is a good thing. Not only can improve the efficiency of communication with MySQL database, but also can easily set some timeouts. For example, the connection timed out and the query timed out.
However, when using MYSQLND, there is a place to pay attention to. Is that the service-side password format does not use the old 16-bit storage format, but rather the new 41-bit storage format.
If the service-side password format is 16 bits, the error will be correct. The information is as follows:

Fatal error:uncaught exception ' pdoexception ' with message ' sqlstate[hy000] [Watts] MYSQLND cannot connect to MySQL 4.1+ u Sing the old insecure authentication. 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/home/hailong.xhl/test.php:8

How to see if your password meets your requirements.

mysql> Select User,length (password) from Mysql.user;
+--------------+------------------+
| user | Length (password) |
+--------------+------------------+
|               Demo | 16 |
|               Demo | 16 |
+--------------+------------------+
The password above is the old 16-bit format. If you want to change to a new 41-bit format, you can use the following command.
Mysql>update mysql.user SET Password = Password (' demo ') WHERE user = ' demo ';
Query OK, 2 rows Affected (0.00 sec)
Rows matched:2 Changed:2 warnings:0
mysql> Select User,length (password) from Mysql.user;
+--------------+------------------+
| user | Length (password) |
+--------------+------------------+
|               Demo | 41 |
|               Demo | 41 |
+--------------+------------------+
mysql> flush Privileges;
Query OK, 0 rows Affected (0.00 sec)

After you have modified your password, you will also need to modify the Old_passwords option in the configuration file. Set the value to 0. That
Old_passwords=0
Then restart MySQL.

Related Article

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.