ich versuche mich via PDO mir meiner lokalen DB zu verbinden, dazu:
Code: Alles auswählen
$server = "TestHost";
$user = "root";
$pwd = "";
$dbname = "test";
try {
$connection = new \PDO("mysql:host=$server;dbname=$dbname", $user, $pwd);
// PDO can throw exceptions rather than Fatal errors, so let's change the error mode to exception
$connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
echo "connection successful";
}
catch(PDOException $e)
{
echo "Connection failed: " . $e->getMessage();
}
Der Zugang wird also verweigert für 'root'... wenn ich auf der Konsole mich anmelde, klappt das ohne Probleme:PDOException in SqlDeliver.php line 30:
SQLSTATE[HY000] [1698] Access denied for user 'root'@'localhost'
Code: Alles auswählen
root@TestHost:/media# mysql
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 14
Server version: 10.1.26-MariaDB-0+deb9u1 Debian 9.1
Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]>