I am trying to connect the database with the following script(cxn-test.php)
<?php
$host = '155.30.136.20';//dummy ip
$user = 'abc_user';
$pass = 'xxxxxxxxx';
$dbname = 'welcome';
$link = mysqli_connect($host, $user, $pass,$dbname);
if (!$link) {
echo "Error: Unable to connect to MySQL." . PHP_EOL;
echo "Debugging errno: " . mysqli_connect_errno() . PHP_EOL;
echo "Debugging error: " . mysqli_connect_error() . PHP_EOL;
exit;
}else {
echo "success" . PHP_EOL;
}
When I am trying on the terminal
php cxn-test.php //success
But when I am trying on localhost i am getting the following error,
curl -s http://localhost/cxn-test.php
Error: Unable to connect to MySQL.
Debugging errno: 2002
Debugging error: Permission denied
This is strange issue it's not working on the localhost but working good on command line.