MySQL 5.7 Password Policy

Source: Internet
Author: User

In MySQL version 5.7, the user password policy is divided into low-level, medium-medium, and super-strong three, with the recommended medium medium level.


When we install MySQL, the user password policy is set by the following command:

Shell> mysql_secure_installation


Use the following command to view an existing password policy

mysql> SHOW VARIABLES like ' validate_password% ';


The validate_password_number_count parameter is the number of digits at least in the password that takes effect when the password policy is medium or above.

The validate_password_special_char_count parameter is the number of special characters such as non-English digits in the password, which takes effect when the password policy is medium or above.

The validate_password_mixed_case_count parameter is the number of uppercase and lowercase characters in the password, which takes effect when the password policy is medium or above.

The validate_password_length parameter is the length of the password, which is generated by the following formula

validate_password_number_count+ validate_password_special_char_count+ (2 * validate_password_mixed_case_count)

The validate_password_dictionary_file parameter is the path to the dictionary file that specifies password validation.

validate_password_policy This parameter can be set to 0, 1, 2, respectively, representing the password strength from low to high, the default value of this parameter is 1, if you want to change the strength of the password, this parameter is changed to 0.


Create User times Error:

mysql> CREATE USER ' test ' @ ' localhost ' identified by ' test ';


ERROR 1819 (HY000): Your password does not satisfy the current policy requirements


Cause of Error:
The password specified does not conform to the existing password policy.


Workaround:
You can set a password according to an existing policy, or you can change the password policy.


① specifying a password according to an existing password policy

mysql> CREATE USER ' test ' @ ' localhost ' identified by ' system#2016 ';


Query OK, 0 rows affected (0.16 sec)


② Change password Policy to reduce password validation criteria

--Change password policy to low

mysql> set global validate_password_policy=0;


Query OK, 0 rows Affected (0.00 sec)

--Change Password length

mysql> set global validate_password_length=0;


Query OK, 0 rows Affected (0.00 sec)

--Minimum password length is 4

mysql> SHOW VARIABLES like ' validate_password% ';mysql> drop user ' test ' @localhost;

Query OK, 0 rows affected (0.07 sec)

--Create a password with a length of 3 error

mysql> CREATE USER ' test ' @ ' localhost ' identified by ' TES ';


ERROR 1819 (HY000): Your password does not satisfy the current policy requirements

--Create a password of length 4, 4 is the minimum length of an existing password policy

mysql> CREATE USER ' test ' @ ' localhost ' identified by ' test ';


Query OK, 0 rows affected (0.01 sec)


MySQL 5.7 Change Password


The password field for the 5.7 version of the MySQL user table has changed, no longer the password field, but the Authentication_string field.


Then change the password to use:

Update Mysql.user set Authentication_string=password (' Password ') where user= ' root ' and Host = ' localhost ';


Or

Set password for ' root ' @ ' localhost ' =password (' password ');



This article is from the SQL Server deep Dive blog, so be sure to keep this source http://ultrasql.blog.51cto.com/9591438/1924475

MySQL 5.7 Password Policy

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.