note 97019 modified in function.mysql-connect by danbrown

From: Date: Mon, 29 Mar 2010 00:36:16 +0000
Subject: note 97019 modified in function.mysql-connect by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-167474@lists.php.net to get a copy of this message
TA point to especially note from the above documentation is that the mysql client library has special behavior around "localhost", in that it will use a socket file instead of TCP/IP. Socket files, while faster, only work if the php script is on the same machine as the database. I found this difficult to overcome when I split off a database server from a server that had a handful of hosted clients all referencing "localhost". After significant effort, and failing with my knowledge of socat and autossh tunnelling as mentioned as a workaround to setup a forward from the socket file to TCP/IP in a mysql forum. I finally resorted to using DNS to reference the DB and no longer provide "localhost". It was a pain to update clients, but live and learn. I tend to work in distributed environments, and now make it a sort of rule of thumb/best practice to use DNS instead of hard coding "localhost" or "x.x.x.x". Hope this helps others out there. Chris Page --was-- A point to especially note from the above documentation is that the mysql client library has special behavior around "localhost", in that it will use a socket file instead of TCP/IP. Socket files, while faster, only work if the php script is on the same machine as the database. I found this difficult to overcome when I split off a database server from a server that had a handful of hosted clients all referencing "localhost". After significant effort, and failing with my knowledge of socat and autossh tunnelling as mentioned as a workaround to setup a forward from the socket file to TCP/IP in a mysql forum. I finally resorted to using DNS to reference the DB and no longer provide "localhost". It was a pain to update clients, but live and learn. I tend to work in distributed environments, and now make it a sort of rule of thumb/best practice to use DNS instead of hard coding "localhost" or "x.x.x.x". Hope this helps others out there. Chris Page http://www.chriswpage.com http://php.net/manual/en/function.mysql-connect.php

« previous php.notes (#167474) next »