问题描述
我在php MySQL中有一个奇怪的问题:
I have a strange problem in php MySQL:
php 与 127.0.0.1
连接,但不与 localhost
连接.
php connects with 127.0.0.1
but not with localhost
.
如何解决这个问题?
推荐答案
localhost 必须在你的 hosts 文件中定义,它在 Windows 和大多数操作系统上是默认的.
localhost must be defined in your hosts file, which it is by default on Windows and most OSs.
检查以下文本文件,看看发生了什么:
Check the following text file and see what's up:
C:WINDOWSsystem32driversetchosts
请注意,hosts"是文件,没有扩展名,它不是文件夹.这个文件应该几乎是空的,如果你看到条目要么你的 AV/垃圾邮件拦截器添加了大量指向 127.0.0.1 的条目,要么讨厌的恶意软件在那里写了垃圾,尽管新条目低于旧条目.localhost 应该是该文件中的第一个条目.
Please note "hosts" is the file, no extension, it's not a folder. This file should be pretty much empty, if you see entries either your AV/spam blocker added a ton of entries that point to 127.0.0.1 or nasty malware has written garbage in there, despite, newer entries are below older ones. Localhost should be the first entry in that file.
这篇关于MySQL 使用 127.0.0.1 但不使用 localhost?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!