1. MySQL用户管理
1. 使用用户名密码登录MySQL数据库
shell> mysql --user=finley --password db_name
2.添加新用户
CREATE USER 'custom'@'localhost' IDENTIFIED BY 'password';
3.给用户添加数据库操作权限
GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP ON bankaccount.* TO 'custom'@'localhost';
4.删除用户
mysql> DROP USER 'jeffrey'@'localhost';
5.设置用户数据库操作资源限制
CREATE USER 'francis'@'localhost' IDENTIFIED BY 'frank'
-> WITH MAX_QUERIES_PER_HOUR 20
-> MAX_UPDATES_PER_HOUR 10
-> MAX_CONNECTIONS_PER_HOUR 5
-> MAX_USER_CONNECTIONS 2;
6.修改用户操作数据库资源限制
mysql> ALTER USER 'francis'@'localhost' WITH MAX_QUERIES_PER_HOUR 100;
7.密码过期设置
ALTER USER 'jeffrey'@'localhost' PASSWORD EXPIRE;
8.MySQL密码的有效时间
SET GLOBAL default_password_lifetime = 180;