Can connect to Mysql via command line but not via browser
[email protected] (Tai Larson) Thu, 3 Sep 2020 21:51:56 +0000
| Newsgroups | php.db |
|---|---|
| Message-ID | <MW3PR15MB3756133F42B08F9FB9742B60FC2C0@MW3PR15MB3756.namprd15.prod.outlook.com> |
I have a MySQL database server and a separate web sever running Apache. Bo=
th are running Centos 8.=20
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 =3D "192.168.10.XXX";
$username =3D "root";
$password =3D "123456789";
$conn =3D new mysqli($servername, $username, $password); if ($conn->connect=
_error) {
die("Connection failed: " . $conn->connect_error); } echo "Connected succ=
essfully"; ?>
I SSH into my web server and run this command "php TestMySQL.php". I recei=
ve the output of "Connected successfully".
When I attempt through my browser or curl, I receive the output of "Connect=
ion failed: Permission denied".
I can also connect to the remote database with the local mysql client.
Thank you all in advance for your help.