摘要:为mysql添加多个用户,并为每个用户配置不同的数据库、数据表访问权限

创建用户

create user wyz identified by 'wyz';

权限管理

授权 all privileges:所有权限。
select:读取权限。
delete:删除权限。
update:更新权限。
create:创建权限。
drop:删除数据库、数据表权限。

grant all privileges on example.* to zhangsan@'%'  with grant option;
flush privileges;

查看权限

select User,Db,Host,Select_priv,Insert_priv,Update_priv,Delete_priv from mysql.db where User = 'zhangsan';

show grants for 'zhangsan';

删除用户

DROP USER IF EXISTS 'username'@'hostname';