Well, it's probably an issue regarding system permissions, or you have only installed mysql-client, but not mysql-server
, so you can not create a UNIX Socket file.
So what you should try first is to install mysql-server:
$ sudo apt-get install mysql-server
If you are sure that mysql-server
is installed, check the main configuration file, which in Debian and Ubuntu should be in /etc/mysql/my.cnf
or /etc/my.cnf
. In my Debian 7 is located at /etc/mysql/my.cnf
.
Your first part of the file should look like this:
Notice that under [client] there is a key called socket
? Well, this is the unix socket file that mysql uses for local connection, by default (unless you do not force it for TCP).
If this file does not exist, create it:
$ sudo touch /var/run/mysqld/mysqld.sock
If it exists, try giving the appropriate permissions and looking at the user group:
$ sudo chown -R mysql:mysql /var/lib/mysql
As a final note, you could also connect using TCP, rather than UNIX socket.