1、创建用户:


CREATE USER 'username'@'host' IDENTIFIED BY 'password';

2、程序中使用的mysql账号应该遵循最小权限原则,不允许夸库查询,故设置专门的账号供程序使用:


grant select,update,delete,insert on database_name.* to 'username'@'%' identified by 'passwd' with grant option;

设置对一个数据库的全部权限:
grant all privileges on database_name.* to 'username'@'%' identified by 'passwd' with grant option;    

3、设置完后将权限信息从内存中写入数据库:


flush privileges;

4、取消用户权限:


revoke all on *.* from username;

标签: none

添加新评论