创建用户
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'@'%';