mysql 创建用户及授权

创建用户

CREATE USER repuser IDENTIFIED BY 'tw.com';

查看用户

SELECT user, host, authentication_string FROM USER WHERE USER='repuser';

修改用户密码

update user set authentication_string='' where user='repuser';
ALTER USER 'repuser'@'%' IDENTIFIED BY 'tw.com';

删除用户

DROP USER repuser;

查看权限

SHOW GRANTS FOR repuser;

授予权限

# 授予repuser用户erp_base全部权限
grant all privileges on erp_base.* to 'repuser'@'%';

# 授予repuser用户全局级全部权限
GRANT ALL PRIVILEGES ON *.* TO 'repuser'@'%' IDENTIFIED BY 'tw.com' WITH GRANT OPTION;

# 授予repuser用户针对erp_base数据库全部权限
GRANT ALL PRIVILEGES ON erp_base.* TO 'repuser';

# 授予repuser用户针对erp_base数据库查询权限
GRANT select on erp_base.* to 'repuser'@'%';

生效(刷新权限)

FLUSH PRIVILEGES;

撤销权限

revoke privileges on erp_base.tablename from 'repuser'@'%';
revoke all privileges on *.* from 'repuser'@'%';
posted @ 2021-04-16 09:20  littlewrong  阅读(102)  评论(0编辑  收藏  举报