Can connect to Mysql via command line but not via browser

From: Date: Thu, 03 Sep 2020 21:51:56 +0000
Subject: Can connect to Mysql via command line but not via browser
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-49184@lists.php.net to get a copy of this message
I have a MySQL database server and a separate web sever running Apache. Both are running Centos 8. I can connect to my database server from my web server via the command line, but I get permission denied whenever I try to connect to the server via a browser. Here is the code I'm running: <?php $servername = "192.168.10.XXX"; $username = "root"; $password = "123456789"; $conn = new mysqli($servername, $username, $password); if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } echo "Connected successfully"; ?> I SSH into my web server and run this command "php TestMySQL.php". I receive the output of "Connected successfully". When I attempt through my browser or curl, I receive the output of "Connection failed: Permission denied". I can also connect to the remote database with the local mysql client. Thank you all in advance for your help.

« previous php.db (#49184) next »