Search code examples
phpmysqlsocketsdrupaldrupal-7

Moving a SIte from Drupal to Raw PHP ... Error: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)


I don't understand this the error,

Error: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

I am not familiar with drupal or any frameworks. Please advice me about this error and if I want to host my raw php site which I created in local WAMP server and connect to the database through, ...

#Database Connection 
$dbc = mysqli_connect('localhost','****user', '***pw', '***db') OR die('Error: '.mysqli_connect_error());

what should I do?


Solution

  • Check whether mysql is running with the following command:

    mysqladmin -u root -p status
    

    And if not try changing your permission to mysql folder. If you are working locally, you can try:

    sudo chmod -R 755 /var/lib/mysql/
    

    Reference Connect to Server