MySQL 8.0.19支持输入3次错误密码,锁定账户功能
例子:>CREATE USER 'hechunyang'@'localhost' IDENTIFIED BY '123456' FAILED_LOGIN_ATTEMPTS 3 PASSWORD_LOCK_TIME 3;
FAILED_LOGIN_ATTEMPTS:代表尝试失败的次数
PASSWORD_LOCK_TIME:代表锁定的时间,单位天,这里为锁定3天。
如果设置UNBOUNDED,代表锁定永久,直到手工解锁。
故意输错3次以上密码,账户被锁定,如下所示:# mysql -hlocalhost -uhechunyang -p123456789 -S /tmp/mysql_hcy.sock
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 3955 (HY000): Access denied for user 'hechunyang'@'localhost'.
Account is blocked for 3 day(s) (3 day(s) remaining) due to 3 consecutive failed logins.
手工解锁:alter user hechunyang@'localhost' ACCOUNT UNLOCK;