How to set the PASSWORD_LOCK_TIME parameter in minutes to lock the account for 5 minutes when configuring the login policy for consecutive incorrect passwords

Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: 配置密码连续错误限制登录策略时,PASSWORD_LOCK_TIME参数如何设置为分钟为单位,锁定账户5分钟

| username: TiDBer_tYhUX7ue

[Test Environment for TiDB] Testing/
[TiDB Version] v6.5.0
[Reproduction Path] What operations were performed when the issue occurred
[Encountered Issue: Issue Phenomenon and Impact]
[Resource Configuration] Go to TiDB Dashboard - Cluster Info - Hosts and take a screenshot of this page
[Attachments: Screenshots/Logs/Monitoring]

| username: 小龙虾爱大龙虾 | Original post link

It probably can’t be done, let’s wait for an expert to take a look.

| username: tidb菜鸟一只 | Original post link

Here’s a simple method for you: write a script that runs every 5 minutes or so to execute the query SELECT * FROM mysql.user a WHERE json_extract(a.User_attributes, '$.Password_locking.auto_account_locked')='Y' to check for locked accounts. If any accounts are found to be locked, unlock them. You can also use the json_extract(User_attributes, '$.Password_locking.auto_locked_last_changed') field to determine when the account was locked.

| username: TIDB-Learner | Original post link

The official documentation states that the lock duration is measured in days. It probably doesn’t support minute-level granularity, but I haven’t tried it.

| username: TiDBer_tYhUX7ue | Original post link

Thank you for your reply.

| username: TiDBer_tYhUX7ue | Original post link

Thank you for the response.

| username: 哈喽沃德 | Original post link

set global tidb_password_lock_time = 300;

| username: TiDBer_tYhUX7ue | Original post link

There is no tidb_password_lock_time parameter…

| username: dba远航 | Original post link

PASSWORD_LOCK_TIME: N | UNBOUNDED. N indicates that the account will be temporarily locked for N days after a login failure. UNBOUNDED means the lock time is indefinite, and the account must be manually unlocked. The value range for N is from 0 to 32767.

| username: 哈喽沃德 | Original post link

Correct!

| username: TiDBer_tYhUX7ue | Original post link

Thank you for the response. I would like to know if TiDB does not support minute-level account locking?