关于Mysql用户的相关操作

基于MySQL 8
如有遗漏,欢迎补充

SELECT * FROM `user`;


#创建用户
CREATE USER `zjm`@`%` IDENTIFIED BY '@GirlFriend999';
#重命名
RENAME USER `zjm`@`%` TO `zjmm`@`%`;
RENAME USER `zjmm` TO `zjm`;

#授权

/*
所有可以授予的权限:
INSERT,SELECT,UPDATE, DELETE, CREATE, DROP
REFERENCES, INDEX, ALTER, CREATE VIEW, SHOW VIEW, TRIGGER 
*/
GRANT SELECT ON girls.`beauty` TO zjm;
GRANT ALL ON girls.`admin` TO zjm WITH GRANT OPTION;
GRANT ALL ON test.* TO zjm; 

#修改密码
SET PASSWORD FOR zjm = '@XXXXXxxxxxxx233';

#查看权限
SHOW GRANTS FOR zjm;

#回收权限
REVOKE INSERT ON girls.`admin` FROM zjm;

#刷新权限
FLUSH PRIVILEGES;
posted @ 2020-03-10 20:41  断腿三郎  阅读(140)  评论(0编辑  收藏  举报