> For the complete documentation index, see [llms.txt](https://viva.gitbook.io/project/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://viva.gitbook.io/project/cun-chu/guan-xi-xing-shu-ju-ku.md).

# Mysql

### 参考文章

{% embed url="<https://xie.infoq.cn/article/4e7de8ce0607bfbe24a5c2e16>" %}

### 使用

例子：创建只读用户

```
-- 创建用户   用户名：readonly  密码：123456 可自行更改 --
CREATE USER 'readonly'@'%' IDENTIFIED BY '123456';

-- 赋予用户只读权限  库名：mydb  用户：readonly --
GRANT SELECT ON mydb.* TO 'readonly'@'%';

-- 刷新权限  --
FLUSH PRIVILEGES;
```

例子：允许root用户远程登录

```
USE mysql;
UPDATE user SET host='%' WHERE user ='root';
FLUSH PRIVILEGES;
```
