Apache can't connect to remote MySQL, but mysql command line from same server can
To see what flags are set on httpd processes
getsebool -a | grep httpd
To allow Apache to connect to remote database through SELinux
setsebool httpd_can_network_connect_db 1
Use -P option makes the change permanent. Without this option, the boolean would be reset to 0 at reboot.
setsebool -P httpd_can_network_connect_db 1