MySQL使用127.0.0.1,但不能使用localhost? [英] MySQL working with 127.0.0.1 but not working with localhost?

查看:629
本文介绍了MySQL使用127.0.0.1,但不能使用localhost?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在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.

如何解决此问题?

推荐答案

本地主机必须在您的主机文件中定义,在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:\WINDOWS\system32\drivers\etc\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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆