Any idea why this is happening?

garrett@bedroom ~ $ mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

Recommended Answers

All 4 Replies

Member Avatar

did you check whether mysqld.sock file exists in /var/run/mysqld ?

If not, you have to locate the correct directory (for example check /var/lib/mysql).
If found, you have to edit your my.cnf usually located in /etc/mysql

my.cnf has a section [client] like mine one:

    port        = 3306
    socket      = /var/run/mysqld/mysqld.sock

Here you can update entry socket.

Member Avatar

Did you already fixed your socket problem?


The problem is that you do not ahve the mysql serve running which is called mysqld. You may not have it installed but and the client and server are two different packages.

I think I had the wrong one installed. Fixed now, thanks guys.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.