tags:

views:

88

answers:

3

Note that you can specify a port number with "port=####", but this port number will be ignored if the host is localhost. If you want to connect to a local port other than the default, use host=127.0.0.1 instead of localhost.

Quoted from this page,has anyone verified if it has been fixed?

A: 

That's most likely not a bug in PDO, but a feature of some database client library. For example, if you use psql (the PostgreSQL client) to connect to localhost, it will use UNIX sockets, but if you use 127.0.0.1, it will use TCP sockets and for that it obviously needs also the port number.

Lukáš Lalinský
+2  A: 

That isn't a bug. That is how MySQL is designed. When the host is "localhost", MySQL Unix clients use a Unix socket rather than a TCP/IP socket for the connection, thus the TCP port doesn't matter.

Reference: "4.2.2. Connecting to the MySQL Server"

outis
you have my vote as "best answer"
andreas
A: 

In my humble opinion you should be checking the PDO/PHP bug related pages.

But i don't think it's a bug. If you are on localhost you don't have to specify a port.

andreas