MySQL MAMP 未连接到本地主机
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/29729926/
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
MAMP not connecting to localhost
提问by Mattc
Just updated MAMP to version 3.2.1 on Yosemite. Both Apache and MySQL servers are green but when I go to my localhost I keep getting: This webpage is not available ERR_NAME_NOT_RESOLVED in browser (Chrome). I've tried incognito browsing and Firefox with the same result, tried both the MAMP default port settings and ports 80 & 3306, tried a reinstall of MAMP and rolling back to previous install of MAMP; all without success.
刚刚在优胜美地将 MAMP 更新到 3.2.1 版。Apache 和 MySQL 服务器都是绿色的,但是当我转到我的本地主机时,我不断收到:此网页在浏览器 (Chrome) 中不可用 ERR_NAME_NOT_RESOLVED。我尝试了隐身浏览和 Firefox,结果相同,尝试了 MAMP 默认端口设置和端口 80 和 3306,尝试重新安装 MAMP 并回滚到以前安装的 MAMP;都没有成功。
Can anyone suggest how to fix this…it's starting to drive me crazy!
任何人都可以建议如何解决这个问题......它开始让我发疯!
回答by ZbadhabitZ
Possible Thoughts;
可能的想法;
In your /Applications/MAMP/htdocs/ folder, is there something in there for your browser to load? Some sort of index.html or index.php file? Could it have gotten removed accidentally?
When you launch MAMP and go to Preferences -> Ports, what is the Apache port? You mentioned you tried the default (8888/8889) and 80/3306, but could the port number somehow have gotten changed?
Is there any chance that some other Apache service is running? This is unlikely as you mentioned that MAMP shows Apache status as green, but it could be worth stopping MAMP, opening Terminal and doing sudo apachectl stop, returning to MAMP and changing the ports to 80/3306, then returning to Terminal and doing sudo apachectl restart. Then return to MAMP and start services again.
If none of the above work, what if you set the Apache port in MAMP's preferences to something random, like 8712, and then try http://localhost:8712/to see if it loads.
在您的 /Applications/MAMP/htdocs/ 文件夹中,是否有可供浏览器加载的内容?某种 index.html 或 index.php 文件?会不会不小心被删了?
当您启动 MAMP 并转到首选项 -> 端口时,Apache 端口是什么?你提到你尝试了默认的 (8888/8889) 和 80/3306,但是端口号会不会以某种方式改变了?
是否有可能正在运行其他一些 Apache 服务?这不太可能,因为您提到 MAMP 将 Apache 状态显示为绿色,但可能值得停止 MAMP,打开终端并执行sudo apachectl stop,返回 MAMP 并将端口更改为 80/3306,然后返回终端并执行sudo apachectl重新启动。然后返回 MAMP 并再次启动服务。
如果以上都不起作用,如果您将 MAMP 首选项中的 Apache 端口设置为随机值,例如 8712,然后尝试http://localhost:8712/以查看它是否加载会怎样。
Let us know if you've tried those already!
如果您已经尝试过这些,请告诉我们!
回答by Jacob
Had a similar issue. If 127.0.0.1 is working then you just need to point localhost to 127.0.0.1. Edit /etc/hosts file (requires sudo) and include
127.0.0.1 localhost
有一个类似的问题。如果 127.0.0.1 正在工作,那么您只需要将 localhost 指向 127.0.0.1。编辑 /etc/hosts 文件(需要 sudo)并包含
127.0.0.1 localhost
That resolved it for me.
那为我解决了。
回答by Kristoffer Sundmyhr
This still happens occasionally when updating macOS.
更新 macOS 时仍会偶尔发生这种情况。
Going through all local Wordpress sites and changing the dev url isn't ideal, though necessary when changing the port.
浏览所有本地 Wordpress 站点并更改 dev url 并不理想,尽管在更改端口时是必要的。
What rather solved the issue for me was restarting Apache as suggested by @ZbadhabitZ, keeping original port number:
为我解决问题的是按照@ZbadhabitZ 的建议重新启动 Apache,并保留原始端口号:
sudo apachectl restart
sudo apachectl restart