Manage database account passwords
If you use UPDATE or INSERT statements to directly modify the permission table in the MySQL database to change account passwords or permissions, the changes are not synchronized to read-only nodes. You must use the methods described in this topic to make these changes. This topic describes how to change database account passwords, configure password expiration, and enable or disable the password validation feature.
Background information
PolarDB supports two types of database accounts: privileged accounts and standard accounts. You can manage all accounts in the console.
For security reasons, PolarDB does not provide a root account.
|
Account type |
Description |
|
Privileged Account |
|
|
Standard Account |
|
|
Global Read-only Account |
|
Change an account password
Log on to the PolarDB console and select the region where the cluster is located. On the Clusters page, click the ID of the destination cluster to go to its product page.
In the navigation pane on the left, click .
Find the destination account, and click Change Password in the Actions column.
In the Change Password dialog box, enter and confirm the new password, and then click OK.
Change an account password from the command line
You can use a privileged account and run the following commands to change an account password:
PolarDB for MySQL 8.0:
ALTER USER 'username'@'host' IDENTIFIED BY '{password}'Parameter
Description
username
The account whose password you want to change.
password
The password of the account.
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 allow the account to log on from any host, use a percent sign (%).
password
The password of the account.
Configure password expiration
You must use a privileged account to configure password expiration. Follow these steps:
Use a privileged account to connect to the database. For more information, see Connect to a database cluster.
Execute the following SQL statement to configure the password expiration time.
ALTER USER 'username'@'hostname' PASSWORD EXPIRE INTERVAL N DAY;In the statement,
usernameis the name of the destination account.hostnameis the name of the host where the destination account is located.Nis the number of days the password is valid.
PolarDB for MySQL 5.6 does not support password expiration configuration.
Enable or disable the password validation feature
You can enable or disable the password validation feature by installing or uninstalling the validate_password plugin. Follow these steps:
Use a privileged account to connect to the database. For more information, see Connect to a database cluster.
Execute the following SQL statements to install or uninstall the
validate_passwordplugin.PolarDB for MySQL 8.0.
Install the
validate_passwordcomponent:INSTALL COMPONENT 'file://component_validate_password';Uninstall the
validate_passwordcomponent:UNINSTALL COMPONENT 'file://component_validate_password';
PolarDB for MySQL 5.7.
Install the
validate_passwordplugin:INSTALL PLUGIN validate_password SONAME 'validate_password.so';Uninstall the
validate_passwordplugin:UNINSTALL PLUGIN validate_password;
PolarDB for MySQL version 5.6 does not support the installation or uninstallation of the
validate_passwordplugin to enable or disable the password validation feature.
Modify validate_password parameters
You cannot modify validate_password parameters in the PolarDB console.