Connect MySQL problem mysqlnd cannot connect to MySQL 4.1+ using the old authentication

Source: Internet
Author: User
Tags mysql client mysql command line

First: PHP5.3 started using MYSQLND as the default MySQL access driver, and from this version will no longer support the use of the old user interface link MySQL, you may see similar hints:

#2000-mysqlnd cannot connect to MySQL 4.1+ using the old authentication

The solution to the problem is not to tweak PHP, but to check your MySQL, and you need to ensure two things:

    • The mysql you are using is 4.1+ or above, and the previous version of 4.1 only supports the use of old 16-bit password storage
    • You are ready to use the new password format (41-bit data) for the connection of the database account used by MySQL

The workaround for problem 2 is to reset the account password and ensure that the standard password () function is used to set the account password, with the following instructions:

--select System library use ' MySQL '-Display the current user and password, note that the new password format should be 41-bit encryption characters, the old 16-bit select ' User ', ' Password ' from ' user ';--Update the password of the specified user, Note Using the function password ()--sometimes for special needs, you can use the Old_password () function to create one or several backward-compatible database accounts with Update ' user ' SET ' password ' =password (' NewPassword ') WHERE ' user ' = ' UserName ';--refresh MySQL permissions library flush privileges;--Finally, don't forget, MySQL command line connection method is: mysql-u [email protected ]-p password
Second: The recent development environment has been upgraded to PHP 5.3.2, the link to remote MySQL error occurred:
Connection failed:sqlstate[hy000] [+] mysqlnd cannot connect to MySQL 4.1+ using old authentication
Remote MySQL db my.cnf:

[Mysqld]

Datadir=/var/lib/mysql

Socket=/var/lib/mysql/mysql.sock

# Default to using old password format for compatibility Withmysql 3.x

# clients (those using the mysqlclient10 compatibilitypackage).

Old_passwords=1

Is the use of a compatible format of the password, and php5.3 php_mysql; Php_pdo_mysql uses an enhanced password, which makes the two mismatched, the most convenient way is to update the DB settings, cancel the Old_passwords
Then in Mysql.mysql.user, update all the user's passwords, such as:
Update user set Password=password (' New password ') where user= ' Thisuser ';
Flush privileges;
Can
But update my.cnf need to restart MySQL, for the server in the application, do not need to update the PHP client, haha

Third article:

New MYSQLND library requires the use of MySQL 4.1 new 41-byte password format

Using the old 16-byte password will cause mysql_connect () and a similar function to produce an error: Mysqlnd cannotconnect to MySQL 4.1+ the using-old authentication. (Mysqlnd cannot use old authentication to connect to MySQL version above 4.1)

Workaround

This is a more perverted study, and it's been a long time finding problems in MY.CNF

1 actually configured old-password=1 or old_password=1 (comment out this sentence)

2 Remove after use Set password for ' root ' @ ' localhost ' = password (' xxx ')

A new 41-bit password problem resolution was generated for root


Fourth: The official way of saying is

MySQL 4.1 and up uses a authentication protocol based on Apassword hashing algorithm that's incompatible with that used Byolder clients. .....

If you are experiencing the above problems after upgrading MySQL to 4.1 or above, make sure your MySQL client is 4.1 or higher.

Please use one of the following 2 methods

One: (use Appserv to modify the MySQL password to use the following methods.)

Mysql> SET PASSWORD for
' Some_user ' @ ' some_host ' = Old_password (' newpwd ');

Second:

mysql> UPDATE mysql.user SET Password =old_password (' newpwd ')
-WHERE Host = ' some_host ' and User = ' some_user ';
mysql> FLUSH privileges;

Above Some_user, Some_host, Newpwd is to fill in.

Excerpt from the network

Connect MySQL problem mysqlnd cannot connect to MySQL 4.1+ using the old authentication

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.