Possible duplicate of this
I am connecting the DB using the PDO.
$DBH = new PDO('mysql:host=localhost;dbname=name','dbusername','dbpassword');
This is not working here.
I am getting the error
SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
But whatever the connection we already done in mysql_connect thats working fine.Could you please help me on this.
Some web hosting providers use custom domain names or IP addresses for MySQL connection, I would advise you first of all to check hosting manual on database connections.
Usually by creating MySQL database through control panel, you would receive example of database connection properties.
Change localhost
to 127.0.0.1
to enforce a connection over TCP rather than a socket connection. My guess is that'll make things work for you.