Connecting to different machine, 'Can't connect through socket' Error

kauchaos

New Member
I'm trying to connect to a different machine:\[code\]$this->_connection = new PDO("mysql: host=MYSQL_SERVER; dbname=MYSQL_DATABASE",MYSQL_USER, MYSQL_PASSWORD, array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"));\[/code\]But PDO barfs:\[quote\] SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)\[/quote\]Infuriatingly, this worked fine with localhost on my dev server - our production setup is an LVS with a separate DB server though, and I can't seem to get PDO to connect to it!Where, oh where have I bungled what here?Edit: This works:\[code\]mysql_connect(MYSQL_SERVER, MYSQL_USER, MYSQL_PASSWORD) or die(mysql_error());mysql_select_db(MYSQL_DATABASE) or die(mysql_error());;echo 'Connected to database <br/>';\[/code\]Note: \[code\]MYSQL_SERVER\[/code\] is not localhost, it is the IP of our database master server. On our dev server, which hosts the dev database, PDO works flawlessly.
 
Back
Top