Check if the MySQL daemon is up and if the path to the socket is correct: this is defined in the configuration file of MySQL, i.e. /etc/mysql/my.cnf, in distro-specific configuration files, like /etc/mysql/debian.cnf, and in the PHP configuration file through pdo_mysql.default_socket=.
Cascading rule is applied: the PHP configuration overrides debian.cnf which overrides my.cnf.
The socket file is used to connect to the local server without passing from the TCP protocol, but you can force it by changing the host to the local IP address:
$pdo = new PDO("mysql:dbname=database;host=127.0.0.1", "username", "password");