After installing the configuration began, however I kept getting this message saying:

 An error occurred while installing the database:                                
  │ ERROR 2002 (HY000): Can't connect to local MySQL server through socket          
  │ '/var/run/mysqld/mysqld.sock' (2)         

I am new to this not sure what is blocking the mysql socket

2 Answers 2


Sounds like a typical permission problem, you need to ensure that your permissions can correctly read and write the database sock file.


If your file my.cnf (usually in the /etc/mysql/ folder) is correctly configured with:


You can check if mysql is running with the following command:

mysqladmin -u root -p status 

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

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

If the above doesn't fix the problem then its likely something else, Visit Can't connect to local MySQL server through socket '/var/mysql/mysql.sock' (38) on Stack Overflow for more answers.

  • seems like it has worked (y) ` mysqladmin -u root -p status Enter password: mysqladmin: connect to server at 'localhost' failed error: 'Access denied for user 'root'@'localhost' (using password: YES)'` then setting the permission: mysqladmin -u root -p status Enter password: Uptime: 4067 Threads: 3 Questions: 3055 Slow queries: 0 Opens: 163 Flush tables: 1 Open tables: 156 Queries per second avg: 0.751 Sep 13, 2016 at 12:46

That's an error in configuration. You need to put localhost or your IP in it.

Follow this steps:

  1. Open /etc/mysql/my.cnf.
  2. Find bind-address, and change its value to the database server host machine's IP address. localhost or
  3. Save and close the file.
  4. Restart apache
  • this is already bind-address = although machine IP is which is going to change in future when I change the router. Sep 13, 2016 at 12:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.