Home > php教程 > PHP开发 > body text

Authentication protocol issues with PHP5 connecting to Mysql5

高洛峰
Release: 2016-12-02 14:00:21
Original
1485 people have browsed it

After MYSQL 4.1, a new user authentication protocol is adopted. For old clients, there will be an error that the authentication protocol is not supported. The following is the solution from the official website?

1Upgrade all client programs to use a 4.1.1 or newer client library.

Update the client library, which requires updating the PHP extension library. PHP no longer provides such an extension library for the old api.

2When connecting to the server with a pre-4.1 client program, use an account that still has a pre-4.1-style password.

Using the previously established account to connect will not work for accounts established under the new authentication protocol

3Reset the password to pre-4.1 style for each user that needs to use a pre-4.1 client program. This can be done using the SET PASSWORD statement and the OLD_PASSWORD() function: mysql> SET PASSWORD FOR

-> 'some_user'@'some_host' = OLD_PASSWORD('newpwd');
IAlternatively, use update and flush privileges: mysql & gt; update mysql.use set password = OLD_PASSWORD host 'and user =' SOME_USER ';

Mysql & GT; Flush Privileges; the password you want to use for ``newpwd'' in the preceding examples. MySQL cannot tell you what the original password was, so you'll need to pick a new one.

This is a good way to create a new one. The account uses the old encryption protocol

4Tell the server to use the older password hashing algorithm:

Start mysqld with the --old-passwords option.

In this way, the advantages of the new authentication protocol cannot be used

5Assign an old -format password to each account that has had its password updated to the longer 4.1 format. You can identify these accounts with the following query: mysql> SELECT Host, User, Password FROM mysql.user

-> WHERE LENGTH(Password) > 16;

For each account record displayed by the query, use the Host and User values ​​and assign a password using the OLD_PASSWORD() function and either SET PASSWORD or UPDATE, as described earlier.

Recover the password that has been upgraded to Old style.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template