This is weird. I have 2 centos boxes, prod (192.168.0.1) and vm (192.168.0.30).
Mysql database sits on prod.
App sits on vm.
From vm, if I type
mysql -u user -p -h 192.168.0.1 -D mydb
Warning: mysqli::mysqli() [function.mysqli-mysqli]: (HY000/2003): Can't connect to
MySQL server on '192.168.0.1' (13) in /var/www/vhosts/myapp/httpdocs/dstest.php
on line 123
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).
max_connections = 500
max_user_connections = 150
key_buffer = 2048M
max_heap_table_size = 256M
# users buffers
innodb_buffer_pool_size = 128M
myisam_sort_buffer_size = 128M
wait_timeout = 240
interactive_timeout = 240
Check here. It looks very similar to your issue.
Edit: added blog content for posterity:
SQLSTATE[HY000]  Can’t connect to MySQL server on ‘xxx.xxx.xxx.xxx’ (13)
One of the things I wish I had found in Google faster when trying to figure out why PHP script refuses to connect to remote MySQL server issuing an error SQLSTATE[HY000]Can't connect to MySQL server on 'xxx.xxxx.xxx.xxx' (13)
I am able to connect from local shell, so first thought was if something wrong with recent Zend Framework upgrade, but after a while I figured out that answer is very simple – SELinux was blocking remote connections from PHP scripts executed by Apache web server. The error code (13) at the end of error message means “permission denied”, so that’s the indication to see if you have similar issue or not.
Anyway, login as root and do
setsebool -P httpd_can_network_connect=1to make it work.
Of course, think twice because you make web server a bit less secure, so don’t do that unless you are sure you need it.