All Products
Search
Document Center

ApsaraDB RDS:Custom password policy

Last Updated:Jun 20, 2026

ApsaraDB RDS for MySQL offers the validate_password plugin to help you create a custom password policy and enhance database security.

Features

ApsaraDB RDS for MySQL supports the validate_password plugin, which lets you define fine-grained password complexity requirements for database accounts. You can control the following rules:

  • Whether a password can be the same as the database account name

  • Minimum password length

  • Minimum number of uppercase and lowercase letters

  • Minimum number of digits

  • Minimum number of special characters

  • Password strength validation policy

Prerequisites

The ApsaraDB RDS for MySQL instance must run MySQL 5.7 or 8.0.

Usage notes

  • The validate_password plugin installation on the primary node is not automatically synchronized to the secondary node

    On instances with a primary/secondary architecture, such as High-availability Edition or Cluster Edition instances, you must manually install the validate_password plugin on both the primary and secondary nodes. You can perform a manual failover to log on to the secondary node and install the plugin. If you install the plugin only on the primary node, the new primary node (originally the secondary) will not have the plugin after a failover, and the password policy will not take effect.

    Note

    After the plugin is installed, password policy parameters configured in the ApsaraDB RDS console are automatically synchronized to the secondary node. You do not need to set them again.

  • Core parameter constraints and system behavior

    The value of length must be greater than or equal to the result of number_count + (2 * mixed_case_count) + special_char_count. If any value change violates this rule, ApsaraDB RDS automatically adjusts the length value to be equal to the result of this formula.

  • Rules enforced by ApsaraDB RDS

    Regardless of your custom policy settings, when you create or modify a password using the ApsaraDB RDS console or calling an API operation (CreateAccount or ResetAccountPassword), the password must always meet the following requirements:

    • The password must be 8 to 32 characters in length.

    • The password must contain characters from at least three of the following character types: uppercase letters, lowercase letters, digits, and special characters (!@#$%^&*()_+-=).

  • Bypassing the enforced minimum length of 8 characters (not recommended)

    You cannot bypass the enforced checks in the ApsaraDB RDS console by changing parameter values. For example, if you set the minimum password length to 5, you must still enter a password of at least 8 characters when you create or modify a password.

    To set a password with fewer than 8 characters, you can use the SET PASSWORD command to bypass the mandatory validation restriction of the ApsaraDB RDS console and directly set a 5-character password. This method is for test environments or special scenarios only, and is not recommended for production environments.

Billing

The custom password policy feature is free of charge.

Step 1: Install the validate_password plugin

  1. Use a privileged account to connect to the ApsaraDB RDS for MySQL instance.

  2. Run the following SQL command to install the validate_password plugin.

    INSTALL PLUGIN validate_password SONAME 'validate_password.so';
  3. Run the following SQL command to verify that the plugin is installed.

    SHOW GLOBAL VARIABLES LIKE 'validate_password%';

    Output similar to the following indicates that the plugin is installed successfully.

    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

Step 2: Modify password policy parameters

  1. Go to the Instances page. In the top navigation bar, select the region in which the RDS instance resides. Then, find the RDS instance and click the ID of the instance.

  2. In the left-side navigation pane, click Parameters.

  3. Search for and modify the parameters that start with loose_validate_password. For more information, see Modify the parameters of an ApsaraDB RDS for MySQL instance.

    Note

    Parameter

    DB versions

    Description

    Example (MySQL 5.7)

    loose_validate_password_check_user_name

    5.7

    Specifies whether the password can be the same as the account name. Valid values:

    • ON (default): The password can be the same as the account name.

    • OFF: The password cannot be the same as the account name.

    OFF: Prohibits the password from being the same as the account name.

    loose_validate_password_policy

    8.0/5.7

    Specifies the password strength policy. Valid values:

    • 0 (LOW): Checks only the password length.

    • 1 (MEDIUM, default value): Checks password length, number of digits, letter case, and special characters.

    • 2 (STRONG): Checks the password length, the number of digits, uppercase and lowercase letters, and special characters, and for matches in a dictionary file.

      Note

      Because ApsaraDB RDS does not support a custom dictionary file, this policy level is equivalent to MEDIUM.

    1: Checks the password length, and the number of digits, uppercase and lowercase letters, and special characters.

    loose_validate_password_length

    8.0/5.7

    The minimum password length.

    • MySQL 5.7: Valid values: 0 to 256. The default value is 8.

    • MySQL 8.0: Valid values: 1 to 12. The default value is 8.

    10: Sets the minimum password length to 10 characters (meeting the requirement: 10 >= 2 + (2 * 2) + 1 = 7).

    loose_validate_password_number_count

    5.7

    The minimum number of digits in a password.

    Valid values: 0 to 256. The default value is 1.

    2: The password must contain at least 2 digits.

    loose_validate_password_mixed_case_count

    5.7

    Specifies the minimum number of both uppercase and lowercase letters required in a password. For example, a value of 1 requires at least one uppercase and one lowercase letter.

    Valid values: 0 to 256. The default value is 1.

    2: Requires the password to contain at least 2 uppercase and 2 lowercase letters.

    loose_validate_password_special_char_count

    5.7

    The minimum number of special characters in a password.

    Valid values: 0 to 256. The default value is 1.

    1: The password must contain at least 1 special character.

Related topics