close

[Solved] Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock in python. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock Error Occurs?

Today I get the following error Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock in python.

How To Solve Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock Error ?

  1. How To Solve Can't connect to local MySQL server through socket '/tmp/mysql.sock Error ?

    To Solve Can't connect to local MySQL server through socket '/tmp/mysql.sock Error For me the problem was I wasn't running MySQL Server. Run server first and then execute mysql.

  2. Can't connect to local MySQL server through socket '/tmp/mysql.sock

    To Solve Can't connect to local MySQL server through socket '/tmp/mysql.sock Error For me the problem was I wasn't running MySQL Server. Run server first and then execute mysql.

Solution 1

For me the problem was I wasn’t running MySQL Server. Run server first and then execute mysql.

$ mysql.server start
$ mysql -h localhost -u root -p

Solution 2

sudo /usr/local/mysql/support-files/mysql.server start 

This worked for me. However, if this doesnt work then make sure that mysqld is running and try connecting.

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also, Read