Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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

1 Answer 1

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.


Excerpt:

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
socket=/var/lib/mysql/mysql.sock

[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

 
discard

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.