公告
财富商城
积分规则
提问
发文
2020-02-10 15:32发布
手持菜刀,她持情操
I have a strange problem in php MySQL:
php connects with 127.0.0.1 but not with localhost.
127.0.0.1
localhost
How to solve this issue?
Try ping localhost in a command line, it may be resolving to ::1: the IP6 equivalent to 127.0.0.1
ping localhost
::1:
To fix it, add (or uncomment) the line:
127.0.0.1 localhost
in C:\WINDOWS\system32\drivers\etc\hosts
C:\WINDOWS\system32\drivers\etc\hosts
Is localhost resolving to the IPv6 address, as opposed to the IPv4, and MySQL is not listening on the v4 address?
The solution is make localhost resolve to the v4 address, OR make MySQL listen on the v6 address.
I remember that being a longstanding and documented feature of Mysql on Windows. Something about the way local sockets work or something.
最多设置5个标签!
Try
ping localhost
in a command line, it may be resolving to::1:
the IP6 equivalent to 127.0.0.1To fix it, add (or uncomment) the line:
in
C:\WINDOWS\system32\drivers\etc\hosts
Is localhost resolving to the IPv6 address, as opposed to the IPv4, and MySQL is not listening on the v4 address?
The solution is make localhost resolve to the v4 address, OR make MySQL listen on the v6 address.
I remember that being a longstanding and documented feature of Mysql on Windows. Something about the way local sockets work or something.