如何启用对 MySQL 服务器的外部访问?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/53491/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 11:59:18  来源:igfitidea点击:

How do I enable external access to MySQL Server?

mysql

提问by Nick Stinemates

How do I enable external access to MySQL Server? I can connect locally but I cannot connect from another box on the network.

如何启用对 MySQL 服务器的外部访问?我可以在本地连接,但无法从网络上的另一个盒子连接。

I just tried

我刚试过

grant all privileges on *.* to root@'%' identified by '*****' with grant option;

And restarted MySQL Server with no success.

并重新启动 MySQL 服务器但没有成功。

回答by Vinko Vrsalovic

You probably have to edit the configuration file (usually my.cnf) to listen in the external interface instead of on localhost only.

您可能必须编辑配置文件(通常是 my.cnf)才能在外部接口中而不是仅在 localhost 上进行侦听。

Change the bind-addressparameter to your machine's IP address.

bind-address参数更改为您机器的 IP 地址。

If this is an old MySQL installation, you should comment out the skip-networking parameter.

如果这是旧的 MySQL 安装,您应该注释掉 skip-networking 参数。

Afterwards, restart MySQL and you'll be set

之后,重新启动 MySQL,您将被设置

回答by Craig Day

Command and syntax looks fine. Have you checked the server is listening on an interface other than 127.0.0.1? By default Im pretty sure it only listens on the localhost address (127.0.0.1)

命令和语法看起来不错。您是否检查过服务器正在侦听 127.0.0.1 以外的接口?默认情况下,我很确定它只侦听本地主机地址 (127.0.0.1)