This follow up may be a bit late but since I am having a similar problem let me continue this thread with a description of the problem I am facing getting the same error. I am attempting to connect from a web server on FEDORA 33 to mysql running on UBUNTU. I have a Java app that connects just fine from the web server box so credentials are known and I am using the same. Questions I have relate to the pre-requisites that need to be in place on each side for the standard PHP-connect via mysqli to work. For the Java app I needed the driver .jar as part of the build path. What has to be in place for PHP as the error now is only telling me “Connect Error (2002) Permission denied”? This is what the .php file has:
<?php
$mysqli = new mysqli('remote IP', 'user', 'pwd', 'db name');
/*
* This is the "official" OO way to do it,
* BUT $connect_error was broken until PHP 5.2.9 and 5.3.0.
*/
if ($mysqli->connect_error) {
die('Connect Error (' . $mysqli->connect_errno . ') '
. $mysqli->connect_error);
}
echo 'Success... ' . $mysqli->host_info . "\n";
$mysqli->close();
?>
Any help would be appreciated, I am looking into SELinux issue on rhw mysql server box but not sure if that is going in the right direction.
Thanks much.