When I use mysql_connect('remote_server', 'user', 'pass') it works fine but when I try the following:
$db = new PDO('mysql:dbname=dbname;mysql:host=remote_server', 'user', 'pass');
It doesn't work. I had mysql-client installed on the web server initially. When trying the PDO connection I was receiving this error:
Connection Failed: SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
So I installed mysql-server and got the following error instead:
Connection Failed: SQLSTATE[28000] [1045] Access denied for user 'user'@'localhost' (using password: YES)
I'm assuming this is because PDO is trying to connect to the local mysql server instead of the remote server. I tried using the local credentials and it connected but this is obviously not what I want. How do I get a connection to the remote server using a PDO connection to a SQL database? Why is it trying to use user@localhost when I specified a remote server in the DSN?