You are using a Unix socket. When reading "localhost" MySQL client libraries don't interpret it as TCP host "localhost" and resolve that name but use the default Socket location. For using TCP on the local machine you have to use 127.0.0.1
as hostname.
To specify the past use unix_socket
instead of host
in the DSN. The location of the socket used for localhost
can be defined at compile time or in some versions of PHP using pdo_mysql.default_socket
in the php.ini
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…