situation as follows:
php script on server a, run by user 'web' (nginx + php-fpm) should access mysql on server b via pdo library, but gets SQLSTATE[HY000] [2003] Can't connect to MySQL server on 'xxx.xxx.xxx.xxx' (4)
server a centos 6.5, php 5.3; server b centos 6.2, mysql 5.1
however, mysql command line client - run as unprivileged user - can connect perfectly fine, reproducible and stable.
once mysql command line client established a successful connection between the servers, the php script runs successfully as well for about 5-7 minutes, presumably until the mysql command line client connection times out.
what am i missing?
here's the test script:
<?php
try {
$dbh = new PDO('mysql:host=111.111.111.111;dbname=myname;port=3306', 'myuser',
'mypass');
echo 'Connected to database';
}
catch(PDOException $e)
{
echo $e->getMessage();
}