drop user if EXISTS testuser, testuser1, testuser2, testuser3, testuser4; drop role if EXISTS role1; CREATE USER testuser; SELECT password_expired, password_lifetime FROM mysql.user WHERE user = 'testuser'; password_expired password_lifetime N NULL CREATE USER testuser1 PASSWORD EXPIRE; SELECT password_expired, password_lifetime FROM mysql.user WHERE user = 'testuser1'; password_expired password_lifetime Y NULL CREATE USER testuser2 PASSWORD EXPIRE DEFAULT; SELECT password_expired, password_lifetime FROM mysql.user WHERE user = 'testuser2'; password_expired password_lifetime N NULL CREATE USER testuser3 PASSWORD EXPIRE NEVER; SELECT password_expired, password_lifetime FROM mysql.user WHERE user = 'testuser3'; password_expired password_lifetime N 0 CREATE USER testuser4 PASSWORD EXPIRE INTERVAL 3 DAY; SELECT password_expired, password_lifetime FROM mysql.user WHERE user = 'testuser4'; password_expired password_lifetime N 3 CREATE ROLE role1; SELECT password_expired, password_lifetime FROM mysql.user WHERE user = 'role1'; password_expired password_lifetime Y NULL ALTER USER testuser PASSWORD EXPIRE NEVER; SELECT password_expired, password_lifetime FROM mysql.user WHERE user = 'testuser'; password_expired password_lifetime N 0 ALTER USER testuser PASSWORD EXPIRE DEFAULT; SELECT password_expired, password_lifetime FROM mysql.user WHERE user = 'testuser'; password_expired password_lifetime N NULL ALTER USER testuser PASSWORD EXPIRE INTERVAL 3 DAY; SELECT password_expired, password_lifetime FROM mysql.user WHERE user = 'testuser'; password_expired password_lifetime N 3 ALTER USER testuser PASSWORD EXPIRE; SELECT password_expired, password_lifetime FROM mysql.user WHERE user = 'testuser'; password_expired password_lifetime Y 3 ALTER USER testuser IDENTIFIED BY '' PASSWORD EXPIRE; SELECT password_expired, password_lifetime FROM mysql.user WHERE user = 'testuser'; password_expired password_lifetime Y 3 ALTER USER testuser IDENTIFIED WITH 'mysql_native_password' AS ''; SELECT password_expired, password_lifetime FROM mysql.user WHERE user = 'testuser'; password_expired password_lifetime N 3 ALTER USER testuser IDENTIFIED BY ''; SELECT password_expired, password_lifetime FROM mysql.user WHERE user = 'testuser'; password_expired password_lifetime N 3 ALTER USER testuser1 PASSWORD EXPIRE NEVER; SELECT password_expired, password_lifetime FROM mysql.user WHERE user = 'testuser1'; password_expired password_lifetime Y 0 ALTER USER testuser1 PASSWORD EXPIRE DEFAULT; SELECT password_expired, password_lifetime FROM mysql.user WHERE user = 'testuser1'; password_expired password_lifetime Y NULL ALTER USER testuser1 PASSWORD EXPIRE INTERVAL 3 DAY; SELECT password_expired, password_lifetime FROM mysql.user WHERE user = 'testuser1'; password_expired password_lifetime Y 3 ALTER USER testuser1 PASSWORD EXPIRE; SELECT password_expired, password_lifetime FROM mysql.user WHERE user = 'testuser1'; password_expired password_lifetime Y 3 ALTER USER testuser1 IDENTIFIED BY '' PASSWORD EXPIRE; SELECT password_expired, password_lifetime FROM mysql.user WHERE user = 'testuser1'; password_expired password_lifetime Y 3 ALTER USER testuser1 IDENTIFIED WITH 'mysql_native_password' AS ''; SELECT password_expired, password_lifetime FROM mysql.user WHERE user = 'testuser1'; password_expired password_lifetime N 3 ALTER USER testuser1 IDENTIFIED BY ''; SELECT password_expired, password_lifetime FROM mysql.user WHERE user = 'testuser1'; password_expired password_lifetime N 3 ALTER USER testuser2 PASSWORD EXPIRE NEVER; SELECT password_expired, password_lifetime FROM mysql.user WHERE user = 'testuser2'; password_expired password_lifetime N 0 ALTER USER testuser2 PASSWORD EXPIRE DEFAULT; SELECT password_expired, password_lifetime FROM mysql.user WHERE user = 'testuser2'; password_expired password_lifetime N NULL ALTER USER testuser2 PASSWORD EXPIRE INTERVAL 3 DAY; SELECT password_expired, password_lifetime FROM mysql.user WHERE user = 'testuser2'; password_expired password_lifetime N 3 ALTER USER testuser2 PASSWORD EXPIRE; SELECT password_expired, password_lifetime FROM mysql.user WHERE user = 'testuser2'; password_expired password_lifetime Y 3 ALTER USER testuser2 IDENTIFIED BY '' PASSWORD EXPIRE; SELECT password_expired, password_lifetime FROM mysql.user WHERE user = 'testuser2'; password_expired password_lifetime Y 3 ALTER USER testuser2 IDENTIFIED WITH 'mysql_native_password' AS ''; SELECT password_expired, password_lifetime FROM mysql.user WHERE user = 'testuser2'; password_expired password_lifetime N 3 ALTER USER testuser2 IDENTIFIED BY ''; SELECT password_expired, password_lifetime FROM mysql.user WHERE user = 'testuser2'; password_expired password_lifetime N 3 ALTER USER testuser3 PASSWORD EXPIRE NEVER; SELECT password_expired, password_lifetime FROM mysql.user WHERE user = 'testuser3'; password_expired password_lifetime N 0 ALTER USER testuser3 PASSWORD EXPIRE DEFAULT; SELECT password_expired, password_lifetime FROM mysql.user WHERE user = 'testuser3'; password_expired password_lifetime N NULL ALTER USER testuser3 PASSWORD EXPIRE INTERVAL 3 DAY; SELECT password_expired, password_lifetime FROM mysql.user WHERE user = 'testuser3'; password_expired password_lifetime N 3 ALTER USER testuser3 PASSWORD EXPIRE; SELECT password_expired, password_lifetime FROM mysql.user WHERE user = 'testuser3'; password_expired password_lifetime Y 3 ALTER USER testuser3 IDENTIFIED BY '' PASSWORD EXPIRE; SELECT password_expired, password_lifetime FROM mysql.user WHERE user = 'testuser3'; password_expired password_lifetime Y 3 ALTER USER testuser3 IDENTIFIED WITH 'mysql_native_password' AS ''; SELECT password_expired, password_lifetime FROM mysql.user WHERE user = 'testuser3'; password_expired password_lifetime N 3 ALTER USER testuser3 IDENTIFIED BY ''; SELECT password_expired, password_lifetime FROM mysql.user WHERE user = 'testuser3'; password_expired password_lifetime N 3 ALTER USER testuser4 PASSWORD EXPIRE NEVER; SELECT password_expired, password_lifetime FROM mysql.user WHERE user = 'testuser4'; password_expired password_lifetime N 0 ALTER USER testuser4 PASSWORD EXPIRE DEFAULT; SELECT password_expired, password_lifetime FROM mysql.user WHERE user = 'testuser4'; password_expired password_lifetime N NULL ALTER USER testuser4 PASSWORD EXPIRE INTERVAL 3 DAY; SELECT password_expired, password_lifetime FROM mysql.user WHERE user = 'testuser4'; password_expired password_lifetime N 3 ALTER USER testuser4 PASSWORD EXPIRE; SELECT password_expired, password_lifetime FROM mysql.user WHERE user = 'testuser4'; password_expired password_lifetime Y 3 ALTER USER testuser4 IDENTIFIED BY '' PASSWORD EXPIRE; SELECT password_expired, password_lifetime FROM mysql.user WHERE user = 'testuser4'; password_expired password_lifetime Y 3 ALTER USER testuser4 IDENTIFIED WITH 'mysql_native_password' AS ''; SELECT password_expired, password_lifetime FROM mysql.user WHERE user = 'testuser4'; password_expired password_lifetime N 3 ALTER USER testuser4 IDENTIFIED BY ''; SELECT password_expired, password_lifetime FROM mysql.user WHERE user = 'testuser4'; password_expired password_lifetime N 3 ALTER USER role1 PASSWORD EXPIRE NEVER; SELECT password_expired, password_lifetime FROM mysql.user WHERE user = 'role1'; password_expired password_lifetime Y 0 ALTER USER role1 PASSWORD EXPIRE DEFAULT; SELECT password_expired, password_lifetime FROM mysql.user WHERE user = 'role1'; password_expired password_lifetime Y NULL ALTER USER role1 PASSWORD EXPIRE INTERVAL 3 DAY; SELECT password_expired, password_lifetime FROM mysql.user WHERE user = 'role1'; password_expired password_lifetime Y 3 ALTER USER role1 PASSWORD EXPIRE; SELECT password_expired, password_lifetime FROM mysql.user WHERE user = 'role1'; password_expired password_lifetime Y 3 ALTER USER role1 IDENTIFIED BY '' PASSWORD EXPIRE; SELECT password_expired, password_lifetime FROM mysql.user WHERE user = 'role1'; password_expired password_lifetime Y 3 ALTER USER role1 IDENTIFIED WITH 'mysql_native_password' AS ''; SELECT password_expired, password_lifetime FROM mysql.user WHERE user = 'role1'; password_expired password_lifetime N 3 ALTER USER role1 IDENTIFIED BY ''; SELECT password_expired, password_lifetime FROM mysql.user WHERE user = 'role1'; password_expired password_lifetime N 3 ALTER USER testuser PASSWORD EXPIRE; SELECT password_expired, password_lifetime FROM mysql.user WHERE user = 'testuser'; password_expired password_lifetime Y 3 SET PASSWORD FOR testuser = '1234'; SELECT password_expired, password_lifetime FROM mysql.user WHERE user = 'testuser'; password_expired password_lifetime N 3 drop user if EXISTS ''@localhost; CREATE USER ''@localhost IDENTIFIED BY 'pass' PASSWORD EXPIRE; Error 3016 (HY000): The password for anonymous user cannot be expired. CREATE USER ''@localhost IDENTIFIED BY 'pass'; ALTER USER ''@localhost PASSWORD EXPIRE; Error 3016 (HY000): The password for anonymous user cannot be expired. DROP USER IF EXISTS 'u1'@'localhost'; CREATE USER 'u1'@'localhost' IDENTIFIED WITH 'mysql_native_password'; ALTER USER 'u1'@'localhost' IDENTIFIED BY 'pass'; ALTER USER 'u1'@'localhost' PASSWORD EXPIRE; SELECT password_expired FROM mysql.user WHERE user = 'u1' and host = 'localhost'; password_expired Y DROP USER IF EXISTS 'u1'@'localhost'; CREATE USER 'u1'@'localhost' IDENTIFIED WITH 'caching_sha2_password'; ALTER USER 'u1'@'localhost' IDENTIFIED BY 'pass'; ALTER USER 'u1'@'localhost' PASSWORD EXPIRE; SELECT password_expired FROM mysql.user WHERE user = 'u1' and host = 'localhost'; password_expired Y DROP USER IF EXISTS 'u1'@'localhost'; CREATE USER 'u1'@'localhost' IDENTIFIED WITH 'tidb_sm3_password'; ALTER USER 'u1'@'localhost' IDENTIFIED BY 'pass'; ALTER USER 'u1'@'localhost' PASSWORD EXPIRE; SELECT password_expired FROM mysql.user WHERE user = 'u1' and host = 'localhost'; password_expired Y drop user 'u1'@'localhost'; show variables like "password_history"; Variable_name Value password_history 0 show variables like "password_reuse_interval"; Variable_name Value password_reuse_interval 0 set global password_history = -1; set global password_reuse_interval = -1; show variables like "password_history"; Variable_name Value password_history 0 show variables like "password_reuse_interval"; Variable_name Value password_reuse_interval 0 set global password_history = 4294967295; set global password_reuse_interval = 4294967295; show variables like "password_history"; Variable_name Value password_history 4294967295 show variables like "password_reuse_interval"; Variable_name Value password_reuse_interval 4294967295 set global password_history = 4294967296; set global password_reuse_interval = 4294967296; show variables like "password_history"; Variable_name Value password_history 4294967295 show variables like "password_reuse_interval"; Variable_name Value password_reuse_interval 4294967295 set session password_history = 42949; Error 1229 (HY000): Variable 'password_history' is a GLOBAL variable and should be set with SET GLOBAL set session password_reuse_interval = 42949; Error 1229 (HY000): Variable 'password_reuse_interval' is a GLOBAL variable and should be set with SET GLOBAL set global password_history = DEFAULT; set global password_reuse_interval = DEFAULT; drop user if EXISTS testReuse; CREATE USER testReuse; SELECT Password_reuse_history,Password_reuse_time FROM mysql.user WHERE user = 'testReuse'; Password_reuse_history Password_reuse_time NULL NULL ALTER USER testReuse PASSWORD HISTORY 5; SELECT Password_reuse_history,Password_reuse_time FROM mysql.user WHERE user = 'testReuse'; Password_reuse_history Password_reuse_time 5 NULL ALTER USER testReuse PASSWORD HISTORY 0; SELECT Password_reuse_history,Password_reuse_time FROM mysql.user WHERE user = 'testReuse'; Password_reuse_history Password_reuse_time 0 NULL ALTER USER testReuse PASSWORD HISTORY DEFAULT; SELECT Password_reuse_history,Password_reuse_time FROM mysql.user WHERE user = 'testReuse'; Password_reuse_history Password_reuse_time NULL NULL ALTER USER testReuse PASSWORD HISTORY 65536; SELECT Password_reuse_history,Password_reuse_time FROM mysql.user WHERE user = 'testReuse'; Password_reuse_history Password_reuse_time 65535 NULL ALTER USER testReuse PASSWORD REUSE INTERVAL 5 DAY; SELECT Password_reuse_history,Password_reuse_time FROM mysql.user WHERE user = 'testReuse'; Password_reuse_history Password_reuse_time 65535 5 ALTER USER testReuse PASSWORD REUSE INTERVAL 0 DAY; SELECT Password_reuse_history,Password_reuse_time FROM mysql.user WHERE user = 'testReuse'; Password_reuse_history Password_reuse_time 65535 0 ALTER USER testReuse PASSWORD REUSE INTERVAL DEFAULT; SELECT Password_reuse_history,Password_reuse_time FROM mysql.user WHERE user = 'testReuse'; Password_reuse_history Password_reuse_time 65535 NULL ALTER USER testReuse PASSWORD REUSE INTERVAL 65536 DAY; SELECT Password_reuse_history,Password_reuse_time FROM mysql.user WHERE user = 'testReuse'; Password_reuse_history Password_reuse_time 65535 65535 ALTER USER testReuse PASSWORD HISTORY 6 PASSWORD REUSE INTERVAL 6 DAY; SELECT Password_reuse_history,Password_reuse_time FROM mysql.user WHERE user = 'testReuse'; Password_reuse_history Password_reuse_time 6 6 ALTER USER testReuse PASSWORD HISTORY 6 PASSWORD HISTORY 7 ; SELECT Password_reuse_history,Password_reuse_time FROM mysql.user WHERE user = 'testReuse'; Password_reuse_history Password_reuse_time 7 6 drop USER testReuse; CREATE USER testReuse PASSWORD HISTORY 5; SELECT Password_reuse_history,Password_reuse_time FROM mysql.user WHERE user = 'testReuse'; Password_reuse_history Password_reuse_time 5 NULL drop USER testReuse; CREATE USER testReuse PASSWORD REUSE INTERVAL 5 DAY; SELECT Password_reuse_history,Password_reuse_time FROM mysql.user WHERE user = 'testReuse'; Password_reuse_history Password_reuse_time NULL 5 drop USER testReuse; CREATE USER testReuse PASSWORD REUSE INTERVAL 5 DAY PASSWORD REUSE INTERVAL 6 DAY; SELECT Password_reuse_history,Password_reuse_time FROM mysql.user WHERE user = 'testReuse'; Password_reuse_history Password_reuse_time NULL 6 drop USER testReuse; CREATE USER testReuse PASSWORD HISTORY 5 PASSWORD REUSE INTERVAL 6 DAY; SELECT Password_reuse_history,Password_reuse_time FROM mysql.user WHERE user = 'testReuse'; Password_reuse_history Password_reuse_time 5 6 drop USER testReuse; CREATE USER testReuse PASSWORD REUSE INTERVAL 6 DAY PASSWORD HISTORY 5; SELECT Password_reuse_history,Password_reuse_time FROM mysql.user WHERE user = 'testReuse'; Password_reuse_history Password_reuse_time 5 6 drop USER testReuse; CREATE USER testReuse PASSWORD HISTORY -5; Error 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your TiDB version for the right syntax to use line 1 column 40 near "-5;" CREATE USER testReuse PASSWORD REUSE INTERVAL -6 DAY; Error 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your TiDB version for the right syntax to use line 1 column 47 near "-6 DAY;" CREATE USER testReuse PASSWORD HISTORY 65535 PASSWORD REUSE INTERVAL 65535 DAY; SELECT Password_reuse_history,Password_reuse_time FROM mysql.user WHERE user = 'testReuse'; Password_reuse_history Password_reuse_time 65535 65535 drop USER testReuse; CREATE USER testReuse PASSWORD HISTORY 65536 PASSWORD REUSE INTERVAL 65536 DAY; SELECT Password_reuse_history,Password_reuse_time FROM mysql.user WHERE user = 'testReuse'; Password_reuse_history Password_reuse_time 65535 65535 drop USER testReuse; CREATE USER testReuse PASSWORD HISTORY DEFAULT PASSWORD REUSE INTERVAL DEFAULT; SELECT Password_reuse_history,Password_reuse_time FROM mysql.user WHERE user = 'testReuse'; Password_reuse_history Password_reuse_time NULL NULL drop USER testReuse; CREATE USER testReuse PASSWORD HISTORY 0 PASSWORD REUSE INTERVAL 0 DAY; SELECT Password_reuse_history,Password_reuse_time FROM mysql.user WHERE user = 'testReuse'; Password_reuse_history Password_reuse_time 0 0 drop user if EXISTS testReuse; CREATE USER testReuse identified by 'test'; SELECT count(*) FROM mysql.password_history WHERE user = 'testReuse'; count(*) 0 set global password_history = 1; alter USER testReuse identified by 'test'; SELECT count(*) FROM mysql.password_history WHERE user = 'testReuse'; count(*) 1 alter USER testReuse identified by 'test'; Error 3638 (HY000): Cannot use these credentials for 'testReuse@%' because they contradict the password history policy. SELECT count(*) FROM mysql.password_history WHERE user = 'testReuse'; count(*) 1 alter USER testReuse identified by 'test1'; SELECT count(*) FROM mysql.password_history WHERE user = 'testReuse'; count(*) 1 DROP USER testReuse; SELECT count(*) FROM mysql.password_history WHERE user = 'testReuse'; count(*) 0 set global password_history = 0; set global password_reuse_interval = 1; CREATE USER testReuse identified by 'test'; SELECT count(*) FROM mysql.password_history WHERE user = 'testReuse'; count(*) 1 alter USER testReuse identified by 'test'; Error 3638 (HY000): Cannot use these credentials for 'testReuse@%' because they contradict the password history policy. alter USER testReuse identified by 'test1'; SELECT count(*) FROM mysql.password_history WHERE user = 'testReuse'; count(*) 2 alter USER testReuse identified by 'test2'; SELECT count(*) FROM mysql.password_history WHERE user = 'testReuse'; count(*) 3 alter USER testReuse identified by 'test3'; SELECT count(*) FROM mysql.password_history WHERE user = 'testReuse'; count(*) 4 update mysql.password_history set Password_timestamp = date_sub(Password_timestamp,interval '1 0:0:1' DAY_SECOND); alter USER testReuse identified by 'test'; SELECT count(*) FROM mysql.password_history WHERE user = 'testReuse'; count(*) 1 drop USER testReuse ; set global password_reuse_interval = 0; CREATE USER testReuse PASSWORD HISTORY 5 PASSWORD REUSE INTERVAL 6 DAY; SELECT count(*) FROM mysql.password_history WHERE user = 'testReuse'; count(*) 0 drop USER testReuse ; CREATE USER testReuse identified by 'test' PASSWORD HISTORY 5; SELECT count(*) FROM mysql.password_history WHERE user = 'testReuse'; count(*) 1 alter USER testReuse identified by 'test1'; alter USER testReuse identified by 'test2'; alter USER testReuse identified by 'test3'; SELECT count(*) FROM mysql.password_history WHERE user = 'testReuse'; count(*) 4 alter USER testReuse identified by 'test'; Error 3638 (HY000): Cannot use these credentials for 'testReuse@%' because they contradict the password history policy. alter USER testReuse identified by 'test4'; SELECT count(*) FROM mysql.password_history WHERE user = 'testReuse'; count(*) 5 alter USER testReuse identified by 'test5'; SELECT count(*) FROM mysql.password_history WHERE user = 'testReuse'; count(*) 5 alter USER testReuse identified by 'test1'; Error 3638 (HY000): Cannot use these credentials for 'testReuse@%' because they contradict the password history policy. alter USER testReuse identified by 'test'; SELECT count(*) FROM mysql.password_history WHERE user = 'testReuse'; count(*) 5 drop USER testReuse; CREATE USER testReuse identified by 'test' PASSWORD HISTORY 5 PASSWORD REUSE INTERVAL 3 DAY; SELECT count(*) FROM mysql.password_history WHERE user = 'testReuse'; count(*) 1 alter USER testReuse identified by 'test1'; alter USER testReuse identified by 'test2'; alter USER testReuse identified by 'test3'; alter USER testReuse identified by 'test4'; alter USER testReuse identified by 'test5'; SELECT count(*) FROM mysql.password_history WHERE user = 'testReuse'; count(*) 6 alter USER testReuse identified by 'test'; Error 3638 (HY000): Cannot use these credentials for 'testReuse@%' because they contradict the password history policy. update mysql.password_history set Password_timestamp = date_sub(Password_timestamp,interval '3 0:0:1' DAY_SECOND) where user = 'testReuse' order by Password_timestamp asc limit 1; alter USER testReuse identified by 'test'; SELECT count(*) FROM mysql.password_history WHERE user = 'testReuse'; count(*) 6 drop USER testReuse; CREATE USER testReuse identified by 'test' PASSWORD HISTORY 5 PASSWORD REUSE INTERVAL 3 DAY; SELECT count(*) FROM mysql.password_history WHERE user = 'testReuse'; count(*) 1 alter USER testReuse identified by 'test1'; alter USER testReuse identified by 'test2'; alter USER testReuse identified by 'test3'; update mysql.password_history set Password_timestamp = date_sub(Password_timestamp,interval '3 0:0:1' DAY_SECOND) where user = 'testReuse' order by Password_timestamp asc limit 1; SELECT count(*) FROM mysql.password_history WHERE user = 'testReuse'; count(*) 4 alter USER testReuse identified by 'test'; Error 3638 (HY000): Cannot use these credentials for 'testReuse@%' because they contradict the password history policy. ALTER USER testReuse PASSWORD HISTORY 3; alter USER testReuse identified by 'test'; SELECT count(*) FROM mysql.password_history WHERE user = 'testReuse'; count(*) 4 drop USER testReuse; set global password_history = 1; set global password_reuse_interval = 1; CREATE USER testReuse identified by 'test' PASSWORD HISTORY 0 PASSWORD REUSE INTERVAL 0 DAY; SELECT count(*) FROM mysql.password_history WHERE user = 'testReuse'; count(*) 0 alter USER testReuse identified by 'test'; SELECT count(*) FROM mysql.password_history WHERE user = 'testReuse'; count(*) 0 drop USER testReuse; set global password_history = 0; set global password_reuse_interval = 360000000; CREATE USER testReuse identified by 'test'; alter USER testReuse identified by 'test1'; alter USER testReuse identified by 'test'; Error 3638 (HY000): Cannot use these credentials for 'testReuse@%' because they contradict the password history policy. set PASSWORD FOR testReuse = 'test'; Error 3638 (HY000): Cannot use these credentials for 'testReuse@%' because they contradict the password history policy. alter USER testReuse identified by ''; alter USER testReuse identified by ''; SELECT count(*) FROM mysql.password_history WHERE user = 'testReuse'; count(*) 2 alter USER testReuse identified by 'test2'; set global password_reuse_interval = 4294967295; alter USER testReuse identified by 'test3'; SELECT count(*) FROM mysql.password_history WHERE user = 'testReuse'; count(*) 4 set PASSWORD FOR testReuse = 'test4'; SELECT count(*) FROM mysql.password_history WHERE user = 'testReuse'; count(*) 5 drop USER testReuse; set global password_reuse_interval = 0; CREATE USER testReuse identified by 'test' PASSWORD HISTORY 5; alter USER testReuse identified by 'test1'; SELECT count(*) FROM mysql.password_history WHERE user = 'testReuse'; count(*) 2 alter USER testReuse identified by 'test1' PASSWORD HISTORY 0; SELECT count(*) FROM mysql.password_history WHERE user = 'testReuse'; count(*) 0 alter USER testReuse identified by 'test1' PASSWORD HISTORY 2 PASSWORD REUSE INTERVAL 1 DAY; alter USER testReuse identified by 'test2'; alter USER testReuse identified by 'test3'; alter USER testReuse identified by 'test1' PASSWORD HISTORY 2 PASSWORD REUSE INTERVAL 0 DAY; drop USER testReuse; set global password_history = 1; CREATE USER testReuse identified by 'test' PASSWORD HISTORY DEFAULT PASSWORD REUSE INTERVAL DEFAULT; SELECT count(*) FROM mysql.password_history WHERE user = 'testReuse'; count(*) 1 ALTER USER testReuse identified by 'test' PASSWORD HISTORY DEFAULT PASSWORD REUSE INTERVAL DEFAULT; Error 3638 (HY000): Cannot use these credentials for 'testReuse@%' because they contradict the password history policy. ALTER USER testReuse identified by 'test1' PASSWORD HISTORY DEFAULT PASSWORD REUSE INTERVAL DEFAULT; SELECT count(*) FROM mysql.password_history WHERE user = 'testReuse'; count(*) 1 set global password_history = DEFAULT; set global password_reuse_interval = DEFAULT; drop user if EXISTS testReuse; CREATE USER testReuse identified with 'caching_sha2_password' by 'test' PASSWORD HISTORY 1 ; SELECT count(*) FROM mysql.password_history WHERE user = 'testReuse'; count(*) 1 alter USER testReuse identified by 'test'; Error 3638 (HY000): Cannot use these credentials for 'testReuse@%' because they contradict the password history policy. set password for testReuse = 'test'; Error 3638 (HY000): Cannot use these credentials for 'testReuse@%' because they contradict the password history policy. alter USER testReuse identified by 'test1'; alter USER testReuse identified with 'tidb_sm3_password'; SELECT count(*) FROM mysql.password_history WHERE user = 'testReuse'; count(*) 0 drop USER testReuse; CREATE USER testReuse identified with 'tidb_sm3_password' by 'test' PASSWORD HISTORY 1 ; SELECT count(*) FROM mysql.password_history WHERE user = 'testReuse'; count(*) 1 alter USER testReuse identified by 'test'; Error 3638 (HY000): Cannot use these credentials for 'testReuse@%' because they contradict the password history policy. set password for testReuse = 'test'; Error 3638 (HY000): Cannot use these credentials for 'testReuse@%' because they contradict the password history policy. alter USER testReuse identified by 'test1'; alter USER testReuse identified with 'caching_sha2_password'; SELECT count(*) FROM mysql.password_history WHERE user = 'testReuse'; count(*) 0 drop USER testReuse; CREATE USER testReuse identified with 'caching_sha2_password' by 'test' PASSWORD REUSE INTERVAL 1 DAY; alter USER testReuse identified by 'test'; Error 3638 (HY000): Cannot use these credentials for 'testReuse@%' because they contradict the password history policy. set password for testReuse = 'test'; Error 3638 (HY000): Cannot use these credentials for 'testReuse@%' because they contradict the password history policy. alter USER testReuse identified by 'test1'; alter USER testReuse identified by 'test2'; alter USER testReuse identified by 'test3'; alter USER testReuse identified by 'test'; Error 3638 (HY000): Cannot use these credentials for 'testReuse@%' because they contradict the password history policy. update mysql.password_history set Password_timestamp = date_sub(Password_timestamp,interval '1 0:0:1' DAY_SECOND) where user = 'testReuse' order by Password_timestamp asc limit 1; alter USER testReuse identified by 'test'; drop USER testReuse; CREATE USER testReuse identified with 'mysql_clear_password' by 'test' PASSWORD REUSE INTERVAL 1 DAY; Error 1524 (HY000): Plugin 'mysql_clear_password' is not loaded CREATE USER testReuse identified with 'tidb_session_token' by 'test' PASSWORD REUSE INTERVAL 1 DAY; Error 1524 (HY000): Plugin 'tidb_session_token' is not loaded CREATE USER testReuse identified with 'auth_socket' by 'test' PASSWORD REUSE INTERVAL 1 DAY; ALTER USER testReuse identified by 'test' ; SELECT count(*) FROM mysql.password_history WHERE user = 'testReuse'; count(*) 0 SELECT authentication_string FROM mysql.user WHERE user = 'testReuse'; authentication_string ALTER USER testReuse identified with 'caching_sha2_password' by 'test' ; SELECT count(*) FROM mysql.password_history WHERE user = 'testReuse'; count(*) 1 drop USER testReuse; SELECT count(*) FROM mysql.password_history WHERE user = 'testReuse'; count(*) 0 CREATE USER testReuse identified with 'tidb_auth_token' by 'test' PASSWORD REUSE INTERVAL 1 DAY; ALTER USER testReuse identified by 'test' ; SELECT count(*) FROM mysql.password_history WHERE user = 'testReuse'; count(*) 0 set password for testReuse = 'test'; SELECT count(*) FROM mysql.password_history WHERE user = 'testReuse'; count(*) 0 ALTER USER testReuse identified with 'caching_sha2_password' by 'test' ; SELECT count(*) FROM mysql.password_history WHERE user = 'testReuse'; count(*) 1 alter USER testReuse identified by 'test'; Error 3638 (HY000): Cannot use these credentials for 'testReuse@%' because they contradict the password history policy. set password for testReuse = 'test'; Error 3638 (HY000): Cannot use these credentials for 'testReuse@%' because they contradict the password history policy. drop USER testReuse; drop user if EXISTS testReuse, testReuse1, testReuse2, testReuse3; CREATE USER testReuse identified by 'test', testReuse1 identified by 'test', testReuse2 identified by 'test' PASSWORD HISTORY 65535 PASSWORD REUSE INTERVAL 65535 DAY; SELECT Password_reuse_history,Password_reuse_time FROM mysql.user WHERE user like 'testReuse%'; Password_reuse_history Password_reuse_time 65535 65535 65535 65535 65535 65535 ALTER USER testReuse identified by 'test1', testReuse1 identified by 'test1', testReuse2 identified by 'test1' PASSWORD HISTORY 3 PASSWORD REUSE INTERVAL 3 DAY; SELECT Password_reuse_history,Password_reuse_time FROM mysql.user WHERE user like 'testReuse%'; Password_reuse_history Password_reuse_time 3 3 3 3 3 3 SELECT count(*) FROM mysql.password_history WHERE user like 'testReuse%' group by user; count(*) 2 2 2 CREATE USER testReuse3 identified by 'test'; SELECT Password_reuse_history,Password_reuse_time FROM mysql.user WHERE user like 'testReuse%'; Password_reuse_history Password_reuse_time 3 3 3 3 3 3 NULL NULL SELECT count(*) FROM mysql.password_history WHERE user like 'testReuse%' group by user; count(*) 2 2 2 ALTER USER testReuse identified by 'test1', testReuse3 identified by 'test1'; Error 3638 (HY000): Cannot use these credentials for 'testReuse@%' because they contradict the password history policy. drop User testReuse, testReuse1, testReuse2, testReuse3; SELECT count(*) FROM mysql.password_history WHERE user like 'testReuse%' ; count(*) 0 drop user if EXISTS testReuse, testReuse1; CREATE USER testReuse identified by 'test' PASSWORD HISTORY 5; SELECT count(*) FROM mysql.password_history WHERE user = 'testReuse'; count(*) 1 alter USER testReuse identified by 'test1'; alter USER testReuse identified by 'test2'; alter USER testReuse identified by 'test3'; SELECT count(*) FROM mysql.password_history WHERE user = 'testReuse'; count(*) 4 rename USER testReuse to testReuse1; SELECT count(*) FROM mysql.password_history WHERE user = 'testReuse'; count(*) 0 SELECT count(*) FROM mysql.password_history WHERE user = 'testReuse1'; count(*) 4 drop user if EXISTS test1; CREATE USER test1 IDENTIFIED WITH 'mysql_native_password' BY '1234'; ALTER USER 'test1' IDENTIFIED BY '222', 'test_not_exist'@'localhost' IDENTIFIED BY '111'; Error 1396 (HY000): Operation ALTER USER failed for 'test_not_exist'@'localhost' SELECT authentication_string FROM mysql.User WHERE User="test1" and Host="%"; authentication_string *A4B6157319038724E3560894F7F932C8886EBFCF ALTER USER IF EXISTS 'test1' IDENTIFIED BY '222', 'test_not_exist'@'localhost' IDENTIFIED BY '111'; show warnings; Level Code Message Note 3162 User 'test_not_exist'@'localhost' does not exist. SELECT authentication_string FROM mysql.User WHERE User="test1" and Host="%"; authentication_string *899ECD04E40F745BD52A4C552BE4A818AC65FAF8