There are methods to work around this:
When “localhost” is set as the mysql host, the connection is set to connect to the specified socket. If no socket is set the hardcoded default of /tmp/mysql.sock is used.
I have noted the following:
I propose we introduce a new option called mysqlnd.localhost_override which enables a system administrator or php distributor to configure how localhost should be overriden.
https://github.com/php/php-src/pull/275
It keeps backward compatability by falling back to current behaviour if mysqlnd.localhost_override is not set.
If the old behaviour were to be deprecated or phased out, a default value of unix:///tmp/mysql.sock may be appropriate. It would also leave the behaviour of “localhost” easier to follow.
If this extension of mysqlnd were to be accepted and merged, the documentation must be updated to include the new option and its syntax.
Example of usage:
mysqlnd.localhost_override = unix:///var/run/mysql/mysqld.sock mysqlnd.localhost_override = tcp://otherhost:3306
0.1 Initial draft 0.2 Withdrawn