I am running a CodeIgniter application on a RHEL7 virtual machine. I am trying to connect it to a another remote DB server. I get a Message: mysqli::real_connect(): (HY000/2002): Permission denied
I have tried the following:
mysql -u username -p -h host.domain.edu -P 1234
, and then the password. I get to the MySQL CLI. Successconfig/database.php
with the credentials on my local app and I am able to connect to the remote DB.The port is already open and listening to traffic from my App server IP, the firewall is not the issue (I think). What am I doing wrong?
After looking around the internet, I learnt that SELinux was preventing httpd to connect to remote servers. I had to set the below 2 flags to true
and that worked for me.
setsebool -P httpd_can_network_connect 1
setsebool -P httpd_can_network_connect_db 1