Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Can't connect to MySQL server on" error when connecting to an external MySQL server

We recently updated PHP to the latest version, and we had a PHP script that was running that is now broken.

Currently, it is not even allowing me to connect to the SQL database at all, and is returning this error:

Failed to connect to MySQL: Can't connect to MySQL server on mysql01.fau.edu (13) 2003

The database itself is located in a Linux environment and I currently cannot get even a simple script as the one below running:

$host = 'mysql01.fau.edu';
$username = '*****';
$password = '*****';
$database = '******';
$connect = mysqli_connect($host,$username,$password,$database);

if (mysqli_connect_errno()) {
    echo 'Failed to connect to MySQL: ' . mysqli_connect_error() . mysqli_connect_errno();
} else {
    echo 'Connected to MySQL! </ br>';
}
like image 604
Evan Beardsley-Dodd Avatar asked Nov 26 '22 07:11

Evan Beardsley-Dodd


1 Answers

For security purposes Mysql is not remotely accessible by default, unless you whitelist the allowed IP in the backend.

You have mentioned it used to work on your laptop which could very possibly change IP.

Use the same network when it was working

like image 88
meda Avatar answered Dec 10 '22 04:12

meda