1, account lockout
Allows administrators to lock / unlock the user account, the statement:
1 Lock
ALTER USER 'hechunyang'@'%' ACCOUNT LOCK; |
When locked, when the user logs on again, the following message appears:
# mysql -h127.0.0.1 -uhechunyang -p -P3312 Enter password: ERROR 4151 (HY000): Access denied, this account is locked |
2 Unlock
ALTER USER 'hechunyang'@'%' ACCOUNT UNLOCK; |
Note: The account is locked out , existing connections are not affected, the new client does not allow connections.
3 View account lockout information
> show create user hechunyang@'%'\G; *************************** 1. row *************************** CREATE USER for hechunyang@%: CREATE USER 'hechunyang'@'%' IDENTIFIED BY PASSWORD '*1DA3AF2348DE66F7554E816DEDC1F1340814842E' ACCOUNT LOCK |
> select * from mysql.global_priv where user='hechunyang'\G; *************************** 1. row *************************** Host: % User: hechunyang Priv: {"access":1073740799,"plugin":"mysql_native_password","authentication_string":"* 1DA3AF2348DE66F7554E816DEDC1F1340814842E","password_last_changed":15 76823835,"account_locked":true} |
2, the user's password expires
1 Set expiration time user
>CREATE USER 'hechunyang'@'%' PASSWORD EXPIRE INTERVAL 1 DAY;
>ALTER USER 'hechunyang'@'%' PASSWORD EXPIRE INTERVAL 1 DAY; |
Note: Only the default unit DAY (day), a minimum of 1 day.
When the user right expires prompted to change password at next logon, as follows:
[email protected][(none)]>show processlist; ERROR 1820 (HY000): You must SET PASSWORD before executing this statement ERROR 1820 (HY000): You must SET PASSWORD before executing this statement ERROR 1820 (HY000): You must SET PASSWORD before executing this statement |
2 解除限制
>ALTER USER 'hechunyang'@'%' PASSWORD EXPIRE NEVER; |
3、支持更改字符集utf8->utf8mb4采用ALGORITHM=INSTANT算法
MariaDB支持表的某一字段,或者整张表,字符集utf8转换为utf8mb4采用ALGORITHM=INSTANT算法(只修改字典信息)
例表结构:
CREATE TABLE t1 ( id int(11) DEFAULT NULL, cid int(11) DEFAULT NULL, name varchar(60) DEFAULT NULL, KEY IX_cid (cid) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; |
DDL变更语句(秒级更改)
alter table t1 modify name varchar(60) charset utf8mb4, ALGORITHM=INSTANT; |
需要注意的地方:
1)反过来utf8mb4->utf8是不支持INSTANT算法的。
2)如果你的字段是latin1拉丁文,转utf8/utf8mb4是不支持INSTANT算法的。
注:在MySQL 8.0.18版本中,修改字符集utf8->utf8mb4是无法使用到INSTANT算法的,需要重建表(ALGORITHM=COPY算法),且会锁表,update/delete/insert/replace into语句会被MDL锁住(Waiting for table metadata lock)
4、字段长度不大于varchar(256),支持采用ALGORITHM=INSTANT算法
例表结构:
CREATE TABLE t1 ( id int(11) DEFAULT NULL, cid int(11) DEFAULT NULL, name varchar(60) DEFAULT NULL, KEY IX_cid (cid) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; |
DDL变更语句(秒级更改)
alter table t1 modify name varchar(80) DEFAULT NULL, ALGORITHM=INSTANT; |
需要注意的地方:
1)varchar(60)减少到varchar(40)是不支持INSTANT算法的。
2)大于并等于varchar(256),这里的256是指字节(UTF8占用3字节),是不支持INSTANT算法的。
注:只对varchar类型采用INSTANT算法,char和int是无效的,仍旧是需要拷贝数据且锁表。