Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Recently I installed LAMP with tasksel. Then I remember I issued some commands to get into the mysql console - it worked. Right now I checked - apache and php modules work perfectly. But as for mysql - whatever commands I issue - it does not start the console. It writes:

Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'

How can I fix it and start mysql? Why did this happen? Where is it installed (I used the default location for the installation), because I dont understand what is started when I issue the commands?

share|improve this question

After Googling, your issue is commonly associated with either a bad hostname, or a misplaced socket file. This Article addresses the latter and proposes a solution.


To make your life easier, you can make a simple change to the MySQL configuration file /etc/my.cnf that will permanently set the socket file used by the mysql client. After making a backup copy of /etc/my.cnf, open it in your favorite editor. The file is divided into sections such as

[mysqld] datadir=/usr/local/mysql/data

[mysql.server] user=mysql basedir=/usr/local/mysql

If there is not currently a section called [client], add one at the bottom of the file and copy the socket= line under the [mysqld] section such as:

[client] socket=/var/lib/mysql/mysql.sock

If there is already a [client] section in the my.cnf file, add or edit the socket line as appropriate. You won’t need to restart your server or any other processes. Subsequent uses of the mysql client will use the proper socket file.

share|improve this answer
@ObsessiveSSOℲ Thanks, I was putting it in as you were commenting! – Kyle Macey Oct 29 '12 at 16:31
the file mysql.sock does not exist anywhere. what shall I do? – John Oct 29 '12 at 17:30

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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