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.tablename to ‘repuser‘@‘%‘ identified by ‘tw.com‘;

# 授予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.tablename to ‘repuser‘@‘%‘ identified by ‘tw.com‘;

生效(刷新权限)

FLUSH PRIVILEGES;

撤销权限

revoke privileges on erp_base.tablename from ‘repuser‘@‘%‘;
REVOKE ALL PRIVILEGES FROM repuser;

mysql 创建用户及授权

上一篇:LINUX使用sig文件验证文件的签名


下一篇:Mysql 数据库中表的排序字段类型要怎么选择?