I have a problem with a Database Connection. It sounds really simple, but I have been searching for a solution for a while now...
My Server:
- Ubuntu 16.04
- Apache 2
- PHP 7.0.15
I put this PHP script into /var/www/html
and gave it chmod 744 / 755
for testing.
try {
$pdo=new PDO ('mysql:dbname=test;host=ip-address', 'user', 'password');
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch(PDOException $e) {
echo 'Verbindung fehlgeschlagen: ' . $e->getMessage();
}
But when I call this file in my browser, the following message shows up:
SQLSTATE[HY000] [2002] Connection refused
The Database User has every rights. I also tried the root user.
Can anyone help me with this one? What could be the problem? I can't find an answer.
Thanks - Flo!