> For the complete documentation index, see [llms.txt](https://huataihuang.gitbook.io/cloud-atlas-draft/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://huataihuang.gitbook.io/cloud-atlas-draft/database/mysql/install_and_upgrade/allow_root_remote_connection_to_mysql.md).

# 允许ROOT用户远程访问MySQL

测试环境（对安全性要求较低）需要设置允许ROOT用户远程访问数据库，方便使用图形管理工具。

> 默认MySQL禁止`root`远程访问

使用以下SQL设置允许：

```sql
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;
FLUSH PRIVILEGES;
```

> 已验证，在 `GRANT` 命令中，需要在字符串 `root` `%` 和 `password` 的前后加上单引号，否则会报错。

并且在配置`my.cnf`文件中设置

```
bind-address = 127.0.0.1
```

注释掉这行：

```
#bind-address = 127.0.0.1
```

> 如果`my.cnf`中有限制IP绑定的设置，修改后需要重启MySQL服务

## 参考

* [How to allow remote connection to mysql](https://stackoverflow.com/questions/14779104/how-to-allow-remote-connection-to-mysql)
