php pdo_mysql使用localhost作为host不行而使用127.0.0.1作为host则OK的原因

The mysql libraries will automatically use Unix sockets if the host of "localhost" is used. To force TCP/IP you need to set an IP address.

原文地址:https://www.cnblogs.com/flytome/p/4366222.html