This section describes the options, system variables, and status
variables that validate_password provides to
enable its operation to be configured and monitored.
To control activation of the
validate_password plugin, use this option:
-
Command-Line Format --validate-password[=value]Type Enumeration Default Value ONValid Values ONOFFFORCEFORCE_PLUS_PERMANENTThis option controls how the server loads the
validate_passwordplugin at startup. The value should be one of those available for plugin-loading options, as described in Installing and Uninstalling Plugins. For example,--validate-password=FORCE_PLUS_PERMANENTtells the server to load the plugin at startup and prevents it from being removed while the server is running.This option is available only if the
validate_passwordplugin has been previously registered withINSTALL PLUGINor is loaded with--plugin-load-add. See Section 6.3.1, “Password Validation Plugin Installation”.
If the validate_password plugin is enabled,
it exposes several system variables that enable configuration
of password checking:
mysql> SHOW VARIABLES LIKE 'validate_password%';
+--------------------------------------+--------+
| Variable_name | Value |
+--------------------------------------+--------+
| validate_password_check_user_name | OFF |
| 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 |
+--------------------------------------+--------+To change how passwords are checked, you can set these system variables at server startup or at runtime. The following list describes the meaning of each variable.
validate_password_check_user_nameCommand-Line Format --validate-password-check-user-name[={OFF|ON}]Introduced 5.7.15 System Variable validate_password_check_user_nameScope Global Dynamic Yes Type Boolean Default Value OFFWhether
validate_passwordcompares passwords to the user name part of the effective user account for the current session and rejects them if they match. This variable is unavailable unlessvalidate_passwordis installed.By default,
validate_password_check_user_nameis disabled. This variable controls user name matching independent of the value ofvalidate_password_policy.When
validate_password_check_user_nameis enabled, it has these effects:Checking occurs in all contexts for which
validate_passwordis invoked, which includes use of statements such asALTER USERorSET PASSWORDto change the current user's password, and invocation of functions such asPASSWORD()andVALIDATE_PASSWORD_STRENGTH().The user names used for comparison are taken from the values of the
USER()andCURRENT_USER()functions for the current session. An implication is that a user who has sufficient privileges to set another user's password can set the password to that user's name, and cannot set that user' password to the name of the user executing the statement. For example,'root'@'localhost'can set the password for'jeffrey'@'localhost'to'jeffrey', but cannot set the password to'root.Only the user name part of the
USER()andCURRENT_USER()function values is used, not the host name part. If a user name is empty, no comparison occurs.If a password is the same as the user name or its reverse, a match occurs and the password is rejected.
User-name matching is case-sensitive. The password and user name values are compared as binary strings on a byte-by-byte basis.
If a password matches the user name,
VALIDATE_PASSWORD_STRENGTH()returns 0 regardless of how othervalidate_passwordsystem variables are set.
validate_password_dictionary_fileCommand-Line Format --validate-password-dictionary-file=file_nameSystem Variable validate_password_dictionary_fileScope Global Dynamic Yes Type File name The path name of the dictionary file that
validate_passworduses for checking passwords. This variable is unavailable unlessvalidate_passwordis installed.By default, this variable has an empty value and dictionary checks are not performed. For dictionary checks to occur, the variable value must be nonempty. If the file is named as a relative path, it is interpreted relative to the server data directory. File contents should be lowercase, one word per line. Contents are treated as having a character set of
utf8. The maximum permitted file size is 1MB.For the dictionary file to be used during password checking, the password policy must be set to 2 (
STRONG); see the description of thevalidate_password_policysystem variable. Assuming that is true, each substring of the password of length 4 up to 100 is compared to the words in the dictionary file. Any match causes the password to be rejected. Comparisons are not case-sensitive.For
VALIDATE_PASSWORD_STRENGTH(), the password is checked against all policies, includingSTRONG, so the strength assessment includes the dictionary check regardless of thevalidate_password_policyvalue.validate_password_dictionary_filecan be set at runtime and assigning a value causes the named file to be read without a server restart.-
Command-Line Format --validate-password-length=#System Variable validate_password_lengthScope Global Dynamic Yes Type Integer Default Value 8Minimum Value 0The minimum number of characters that
validate_passwordrequires passwords to have. This variable is unavailable unlessvalidate_passwordis installed.The
validate_password_lengthminimum value is a function of several other related system variables. The value cannot be set less than the value of this expression:validate_password_number_count + validate_password_special_char_count + (2 * validate_password_mixed_case_count)If
validate_passwordadjusts the value ofvalidate_password_lengthdue to the preceding constraint, it writes a message to the error log. validate_password_mixed_case_countCommand-Line Format --validate-password-mixed-case-count=#System Variable validate_password_mixed_case_countScope Global Dynamic Yes Type Integer Default Value 1Minimum Value 0The minimum number of lowercase and uppercase characters that
validate_passwordrequires passwords to have if the password policy isMEDIUMor stronger. This variable is unavailable unlessvalidate_passwordis installed.For a given
validate_password_mixed_case_countvalue, the password must have that many lowercase characters, and that many uppercase characters.validate_password_number_countCommand-Line Format --validate-password-number-count=#System Variable validate_password_number_countScope Global Dynamic Yes Type Integer Default Value 1Minimum Value 0The minimum number of numeric (digit) characters that
validate_passwordrequires passwords to have if the password policy isMEDIUMor stronger. This variable is unavailable unlessvalidate_passwordis installed.-
Command-Line Format --validate-password-policy=valueSystem Variable validate_password_policyScope Global Dynamic Yes Type Enumeration Default Value 1Valid Values 012The password policy enforced by
validate_password. This variable is unavailable unlessvalidate_passwordis installed.validate_password_policyaffects howvalidate_passworduses its other policy-setting system variables, except for checking passwords against user names, which is controlled independently byvalidate_password_check_user_name.The
validate_password_policyvalue can be specified using numeric values 0, 1, 2, or the corresponding symbolic valuesLOW,MEDIUM,STRONG. The following table describes the tests performed for each policy. For the length test, the required length is the value of thevalidate_password_lengthsystem variable. Similarly, the required values for the other tests are given by othervalidate_password_variables.xxxPolicy Tests Performed 0orLOWLength 1orMEDIUMLength; numeric, lowercase/uppercase, and special characters 2orSTRONGLength; numeric, lowercase/uppercase, and special characters; dictionary file validate_password_special_char_countCommand-Line Format --validate-password-special-char-count=#System Variable validate_password_special_char_countScope Global Dynamic Yes Type Integer Default Value 1Minimum Value 0The minimum number of nonalphanumeric characters that
validate_passwordrequires passwords to have if the password policy isMEDIUMor stronger. This variable is unavailable unlessvalidate_passwordis installed.
If the validate_password plugin is enabled,
it exposes status variables that provide operational
information:
mysql> SHOW STATUS LIKE 'validate_password%';
+-----------------------------------------------+---------------------+
| Variable_name | Value |
+-----------------------------------------------+---------------------+
| validate_password.dictionary_file_last_parsed | 2019-10-03 08:33:49 |
| validate_password_dictionary_file_words_count | 1902 |
+-----------------------------------------------+---------------------+The following list describes the meaning of each status variable.
validate_password_dictionary_file_last_parsedWhen the dictionary file was last parsed.
validate_password_dictionary_file_words_countThe number of words read from the dictionary file.