I started a new small project on MAC OS X Yosemite and i have a problem to connect to MySQL with PDO in PHP 5.5.22 like this:
$dsn = 'mysql:dbname=testdb;host=127.0.0.1';
$user = 'dbuser';
$password = 'dbpass';
try {
$dbh = new PDO($dsn, $user, $password);
} catch (PDOException $e) {
echo 'Connection failed: ' . $e->getMessage();
}
try
{
$bdd = new PDO('mysql:host=localhost;dbname=LOYER;charset=utf8', 'root', 'root');
}
catch (Exception $e)
{
die('Erreur : ' . $e->getMessage());
}
The first respond:
Connection failed: SQLSTATE[HY000] [2002] Connection refused
and the second :
Erreur : SQLSTATE[HY000] [2002] No such file or directory
Anyone got an idea ?
I already looked for the socket and nothing seems wrong.