I wrote a random test.php. Linked database test, the results show:
Could not connect:mysqlnd cannot connect to MySQL 4.1+ using 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
Description is not, the problem of configuration files, is to modify the password problem, put the above issues to Baidu:
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
| code is as follows |
copy code |
old_passwords = 1 //old_passwords = 1 is 16-bit //so first //set old_passwords = 0; //so that the length of the new password becomes 41-bit |
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 code is as follows |
Copy Code |
Mysql> SELECT Length (PASSWORD (' xyz ')); |
The results are as follows: obviously 16-bit
The old password hashes are characters, the new ones are.
2. Change the format of the "Passwords in the" database to the new format
Connect to the database, and run the following query:
| The code is as follows |
Copy Code |
mysql> SELECT User, Length (' Password ') from ' MySQL '. ' User '; |
This'll show your which passwords are in the old format, ex:
Notice here This is each user can have multiple rows (one for each different host specification).
To update the password for each user, run the following:
| The code is as follows |
Copy Code |
UPDATE mysql.user SET Password = Password (' Password ') WHERE user = ' username '; |
As shown in figure:
Finally, flush privileges:
| code is as follows |
copy code |
flush privileges; |
last query again
| The code is as follows |
Copy Code |
mysql> SELECT User, Length (' Password ') from ' MySQL '. ' User '; |
The results are as follows: (become 41-digit, successful)
Quit exit after success
Finally restart MySQL
| The code is as follows |
Copy Code |
Service mysqld Restart |
Ok
| code is as follows |
copy code |
MYSQL> SET old_passwords = 0; UPDATE mysql.user SET Password = Password (' testpass ') WHERE user = ' testuser ' limit 1; SELECT LENGTH (passwo RD) from Mysql.user WHERE user = ' testuser '; FLUSH privileges; |