Administrator modifies MySQL 5.7.9 new version of the root password method and some new changes to organize

Source: Internet
Author: User
Tags mysql version

MySQL version 5.7, the enhanced password authentication mechanism, the network said when installed in the/root/.mysql_secret file will generate a default password, which has been removed since the 5.7.6 version.

For if a default password is generated, there is a version on the web that reads as follows:

1, modify the configuration file, generally in/etc/my.cnf, in the [Mysqld] field under the Skip-grant-tables field, to ignore the permission validation;

2. Restart the MySQL server, the CentOS 7.0 Operation command is:

Systemctl Restart Mysqld.service

3, use mysql-u root-p login data, password directly enter;

4, modify the MySQL database (name), the User table authentication_string field, modify the command as follows:

Mysql> UpdateMysql.User SetAuthentication_string=Password'New_password')where User='Root'  andHost='localhost'; MySQL>FlushPrivileges; MySQL>Quit

5, modify the configuration file, remove Skip-grant-tables, revert to the original appearance, and then re-MySQL server.

6. Use the password set in step 4th to log in to the MySQL server.

7, through set Password=password (' New_password '); command to reset the password;

The above method, in the early version of MySQL 5.7, is still very useful, but after the MySQL 5.7.6 version, the last point of resetting the password is always unable to take effect, will come out the following error.

1819  not  Current policy requirements

At the same time, other operations cannot be performed.

This is because, starting with MySQL 5.7, the password has an expiration date concept, and because of security level issues, it needs to be set up in other ways. Another point to note is that since 5.7.6 began to discard the password () function and cannot set the old_password=1, this is really a more tortuous process of exploration.

Well, first of all, the MySQL 5.7.9 above the password setting method to tidy up.

Most of the content is the same as the above, the key is after the 4th step, write the value written in authentication_string (this is because the password () function is obsolete)

Use the following command instead of the 7th step, set Password=password (' New_password ') method.

 mysql>  alter  user   " jeffrey   '  @ '  localhost   

In fact, the above command has a simplified version, the command is as follows

MySQL>ALTERuseruserby'news_password'   1819 not current policy requirements 

The above error message appears, which is related to the security level of the password, and check the security level command as follows

Mysql>SHOW VARIABLES like 'validate_password%';+--------------------------------------+--------+|Variable_name|Value|+--------------------------------------+--------+|Validate_password_dictionary_file|        ||Validate_password_length| 8      ||Validate_password_mixed_case_count| 1      ||Validate_password_number_count| 1      ||Validate_password_policy|MEDIUM||Validate_password_special_char_count| 1      |+--------------------------------------+--------+

Via SET GLOBAL validate_password_policy= ' low '; command, after lowering the security level, can be used directly, the limit is must be 8 characters or more;

A more detailed description of the safety level is given below

    • LOW The policy only tests the password length. The password must be at least 8 characters in length.

    • MEDIUM Policy conditions the password must contain at least 1 numeric characters, 1 uppercase and lowercase characters, and 1 special (nonalphanumeric) characters.

    • STRONG Policy situation the password substring length of 4 or longer does not match the word in the dictionary file if a person is specified.

Finally, to resolve the problem of password invalidation, add the following fields under the [Mysqld] field of the configuration file.

[mysqld] Default_password_lifetime = 0

You can also set it from the command line  

ALTER USER ' Script '@'localhost' PASSWORD EXPIRE never

Original: http://www.cnblogs.com/Gbeniot/p/5156633.html

Administrator modifies MySQL 5.7.9 new version of the root password method and some new changes to organize

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.