Resolve modify root password link not on MySQL database

Source: Internet
Author: User
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:
As shown in figure:
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;

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.