limit_action.md 776 字节
Newer Older
M
Mars Liu 已提交
1 2 3 4
# 限制用户使用资源

Joe 需要限制数据分析组(role analysis)的用户, 每小时查询次数不能超过10000次。应该怎么操作?

M
Mars Liu 已提交
5 6
<hr/>

M
Mars Liu 已提交
7
点击进入[MySQL实战练习环境](https://mydev.csdn.net/product/pod/new?image=cimg-centos7-skilltreemysql&connect=auto&create=auto&utm_source=skill)
M
Mars Liu 已提交
8 9
* `show databases` 列出所有数据库
* `show tables` 列出所有表
M
Mars Liu 已提交
10

M
Mars Liu 已提交
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
## 答案

```mysql
alter user analysis with MAX_QUERIES_PER_HOUR 10000;
```

## 选项

### A

```mysql
set user analysis with MAX_QUERIES_PER_HOUR 10000;
```


### B

```mysql
alter role analysis with MAX_QUERIES_PER_HOUR 10000;
```

### C

```mysql
alter role analysis with MAX_QUERIES_PER_HOUR=10000;
```

### D

```mysql
alter user analysis set MAX_QUERIES_PER_HOUR 10000;
```