Spechal
Spechal

Reputation: 2716

PHP MySQL connection without socket file

If the socket file reporting in phpinfo() does not exist, does it create a TCP connection to the MySQL server?

I am asking because A is a web server and B is a MySQL server. A does not have the /var/lib/mysql directory as defined in phpinfo() but it is still able to connect to server B.

Upvotes: 2

Views: 1412

Answers (2)

sreimer
sreimer

Reputation: 4998

The socket is the default for connecting to a local MySQL server. Otherwise, a TCP connection is used.

If you want to use a TCP connection for a local server, use the following:

mysql -h 127.0.0.1 -P 3306

Upvotes: 0

Marc B
Marc B

Reputation: 360872

If they're distinct servers, then it'd be a TCP connection. file sockets do not function over the network - they're local usage only.

Upvotes: 3

Related Questions