For users who have multiple failed login attempts, OceanBase AI Database locks the account to prevent malicious password attacks, thereby improving database security.
Login failure handling strategy
In OceanBase AI Database, you can set the tenant-level configuration item connection_control_failed_connections_threshold to specify the threshold for control over failed login attempts. If the number of consecutive failed login attempts exceeds the value of this configuration item, the system locks the account.
The connection_control_failed_connections_threshold configuration item specifies the threshold for failed login attempts. The default value is 0, and the value range is [0, 2147483647]. Take note of the following items when you specify a value:
A value of
0disables this feature. In this case, no action is taken against failed login attempts.If you set the configuration item to a value other than
0, the account of a user is locked when the number of failed login attempts by the user exceeds the specified value. The lock duration is calculated by using the following formula:MIN(MAX((current_failed_login_num + 1 - connection_control_failed_connections_threshold) * 1000, connection_control_min_connection_delay), connection_control_max_connection_delay)Where:
current_failed_login_numindicates the number of consecutive failed login attempts by the user. The value ofcurrent_failed_login_nummust be greater than or equal to that ofconnection_control_failed_connections_threshold.The
connection_control_min_connection_delayconfiguration item specifies the minimum lock duration in milliseconds after the number of consecutive failed login attempts exceeds the specified threshold. The value range is [1000, 2147483647], and the default value is1000.For more information about the
connection_control_min_connection_delayconfiguration item, see connection_control_min_connection_delay.The
connection_control_max_connection_delayconfiguration item specifies the maximum lock duration in milliseconds after the number of consecutive failed login attempts exceeds the specified threshold. The value range is [1000, 2147483647], and the default value is2147483647.For more information about the
connection_control_max_connection_delayconfiguration item, see connection_control_max_connection_delay.
Configuration example
Log in to a MySQL tenant of a cluster as the root user.
obclient -uroot@mysql -h127.1 -P2881 -p********Set the threshold of failed login attempts to 5, and set the minimum lock duration and maximum lock duration after the number of consecutive failed login attempts reaches the specified threshold to 60,000 ms and 360,000 ms respectively.
Here is an example:
obclient> ALTER SYSTEM SET connection_control_failed_connections_threshold=5; obclient> ALTER SYSTEM SET connection_control_min_connection_delay=60000; obclient> ALTER SYSTEM SET connection_control_max_connection_delay=360000;For more information about the configuration items, see Set parameters.
Create a user.
obclient> CREATE USER 'test' IDENTIFIED BY '*******'; Query OK, 0 rows affected (0.04 sec)Verify the login failure handling strategy. If you enter an incorrect password five consecutive times, your account will be locked.
obclient -h127.1 -P2881 -utest@mysql -p*******; obclient: [Warning] Using a password on the command line interface can be insecure. ERROR 5039 (01007): User lockedLog in to a MySQL tenant of OceanBase AI Database as the
rootuser to view the login failure information.obclient> SELECT * FROM information_schema.CONNECTION_CONTROL_FAILED_LOGIN_ATTEMPTS; +-------------+-----------------+ | USERHOST | FAILED_ATTEMPTS | +-------------+-----------------+ | 'test'@'%' | 5 | +-------------+-----------------+ 1 row in set (0.005 sec)Unlock the user.
Notice
If you log in as the administrator, you can directly lock and unlock users. If you log in as a regular user, you must have the global
ALTER USERprivilege to lock and unlock users. For more information about how to view and grant user privileges, see View user privileges and Grant privileges directly.obclient> ALTER USER test ACCOUNT UNLOCK; Query OK, 0 rows affected (0.03 sec)