create_user.md 1013 字节
Newer Older
M
Mars Liu 已提交
1 2 3 4 5
# 创建用户

Joe 要给数据组的 John 创建一个用户,他希望John 能够从 `192.168.7.42` 登录 goods 数据库查询数据,
用户第一次登录时使用密码 `goods123`,登录后必须设定一个新密码,那么应该用哪个语句?

M
Mars Liu 已提交
6 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 10 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
## 答案

```mysql
create user 'john'@'192.168.7.42' identified by 'goods123' password expire;
grant select on goods.* to 'john'@'192.168.7.42';
flush privileges;
```

## 选项

### A

```mysql
create user 'john'@'192.168.7.42' identified by 'goods123';
grant select on goods.* to 'john'@'192.168.7.42';
flush privileges;
```

### B

```mysql
create user 'john'@'192.168.7.42' identified by 'goods123';
grant usage on goods.* to 'john'@'192.168.7.42';
flush privileges;
```

### C

```mysql
create user 'john'@'192.168.7.42' identified by 'goods123' on database goods;
flush privileges;
```