I have put PushChatServer dir in htdocs folder and create database puschat try to run @\"http://localhost/PushChatServer/api/test/database.php\"
Then I got following
I had the same error using PHP 5.6.30 (macOS Sierra) with the simple PDO code like:
$pdo = new PDO('mysql:host=localhost;dbname=db_php', 'root', '');
And I received the same error message. To fix, I changed "localhost" for IP (loopback) "127.0.0.1" in my code:
$pdo = new PDO('mysql:host=127.0.0.1;dbname=db_php', 'root', '');
To test the connection:
$ php -r "new PDO('mysql:host=127.0.0.1;dbname=db_php', 'root', '');"
This work's for me!