Use the PolarDB console or SQL statements to change account passwords, set password expiration policies, and control password strength validation.
Always use the methods described in this topic to change account passwords or permissions. Running UPDATE or INSERT on the MySQL permission tables bypasses PolarDB's replication mechanism — changes will not be synchronized to read-only nodes.
Version compatibility
The following table summarizes version support for each feature:
| Feature | PolarDB for MySQL 5.6 | PolarDB for MySQL 5.7 | PolarDB for MySQL 8.0 |
|---|---|---|---|
| Change password (console) | Supported | Supported | Supported |
| Change password (SQL) | Supported | Supported | Supported |
| Password expiration | Not supported | Supported | Supported |
validate_password extension | Not supported | Supported | Supported |
Account types
PolarDB for MySQL supports two account types.
Root accounts cannot be created or used in PolarDB for MySQL.
| Account type | Description |
|---|---|
| Privileged account | One privileged account per cluster. It can manage all standard accounts and databases, create databases and standard accounts, authorize standard accounts, and disconnect any standard account. Create and manage privileged accounts in the PolarDB console only. |
| Standard account | Multiple standard accounts per cluster (maximum depends on the database engine). Create and manage standard accounts in the console or with SQL statements. A standard account can only access databases it has been authorized for, and cannot create databases, other standard accounts, or disconnect other accounts. |
Change a password in the console
Log on to the PolarDB console.
In the top navigation bar, select the region where your cluster is deployed.
Find the cluster and click its ID.
In the left-side navigation pane, choose Settings and Management > Accounts.
Find the account and click Change Password in the Actions column.
In the Change Password dialog box, enter and confirm the new password, then click OK.
Change a password with SQL statements
Connect to the cluster using the privileged account, then run the statement for your MySQL version.
PolarDB for MySQL 8.0
ALTER USER 'username'@'host' IDENTIFIED BY '{password}'PolarDB for MySQL 5.6 or 5.7
SET PASSWORD FOR 'username'@'host' = PASSWORD('password');| Parameter | Description |
|---|---|
username | The account whose password you want to change. |
host | The host from which the account can log on to the database. Set to % to allow login from all hosts. |
password | The new password. |
Set password expiration
Password expiration requires the privileged account. PolarDB for MySQL 5.6 does not support this feature.
Connect to the cluster using the privileged account.
Run the following statement:
ALTER USER 'username'@'hostname' PASSWORD EXPIRE INTERVAL N DAY;Parameter Description usernameThe account to configure. hostnameThe host from which the account can log on to the database. NThe number of days before the password expires.
Enable or disable password strength validation
The validate_password extension enforces password strength policies. Install or uninstall it using the privileged account. PolarDB for MySQL 5.6 does not support this extension.
Connect to the cluster using the privileged account.
Run the statement for your MySQL version:
PolarDB for MySQL 8.0
Install:
INSTALL COMPONENT 'file://component_validate_password';Uninstall:
UNINSTALL COMPONENT 'file://component_validate_password';
PolarDB for MySQL 5.7
Install:
INSTALL PLUGIN validate_password SONAME 'validate_password.so';Uninstall:
UNINSTALL PLUGIN validate_password;
Modify validate_password parameters
The validate_password parameters cannot be modified in the PolarDB console. To modify these parameters, join DingTalk group 35365027095 to get technical support. A PolarDB chatbot assistant is also available 24/7 in the group.