权限 | 权限级别 | 权限说明 |
---|---|---|
create | 数据库、表或索引 | 建立数据库、表、索引 |
drop | 数据库或表 | 删除数据库或表 |
alter | 表 | 更改表,好比添加字段、索引 |
delete | 表 | 删除数据 |
index | 表 | 索引 |
insert | 表 | 插入 |
select | 表 | 查询 |
update | 表 | 更新 |
create view | 视图 | 建立视图 |
execute | 存储过程 | 执行存储过程 |
MySQL中权限的设置也是存储在数据库中的:mysql
完整语法:sql
/* 建立用户 */ create user '用户名'@'访问限制' identified by '密码'; /* 赋予anthony用户select、insert权限 *.*表明全部数据库对象 */ grant select,insert on *.* to 'anthony'@'localhost'; /* 建立用户而且赋予权限 */ grant select,insert on *.* to 'anthony'@'localhost' identified by '密码'; /* 加上with grant option(给别人权限) */ grant select,insert on *.* to 'anthony'@'localhost' identified by '密码' with grant option;
flush privileges;
/* 当前用户权限 */ show grants; /* 特定用户权限 */ show grants for 用户@访问限制;
语法:revoke 权限 on 数据库对象 from 用户;数据库
使用revoke撤销所有权限, 操做者必须拥有全局的create user或update权限
revoke all on *.* from anthony;
drop user 用户@限制访问;ide
drop user 'anthony'@'%';