How to configure WordPress Database for CentOS 7

Try to disable temporarily SELinux on the web server, with the command:

sudo setenforce 0

If the error disappears after disabling SELinux, re-enable it with:

sudo setenforce 1

and then allow httpd to connect to a MySql server through the network with:

sudo setsebool -P httpd_can_network_connect_db 1
sudo setsebool -P httpd_can_network_connect 1