I've been struggling with this issue for a really long time. Can someone please advise me on how to get mysql working?

root@me:~# start mysql
start: Job is already running: mysql
root@me:~# mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

What boggles the mind is that it shows no mysql processes being run even though the above bash says otherwise.

~# ps -ef | grep mysql
root      8968  1631  0 15:24 pts/0    00:00:00 grep --color=auto mysql
  • Does this file exist? /var/run/mysqld/mysqld.sock Delete it. It is a stale socket file. Then try to start. – user8290 Jan 3 '12 at 0:08
  • mysqld directory is already empty =( – user784637 Jan 3 '12 at 0:13
  • Hmm? This is for the socket file. 'ls -la /var/run/mysqld/mysqld.sock' Got it? Delete it. – user8290 Jan 3 '12 at 0:21
  • already tried that =( – user784637 Jan 3 '12 at 0:36
  • OP are you still looking for an answer? If so, you may need to repost your question as this is flagged for closure. Regards, – Ringtail Mar 28 '12 at 0:29

use the command sudo nano /etc/mysql/my.cnf and change the bind address to your local host or then save and close the my.cnf window.

Then run the below command

sudo service mysql start

then try login mysql -u root -p

  • not working for me. – LoveToCode Jul 29 '16 at 5:14

check following steps:-

1) in my.cnf check the scoket location

2)check the mysql data directory permissions .

3)use following if u don't have password mysql -uroot -p password:just press enter


In spite of it seems that using start and stop it is the new standard way to launch daemons, I still prefer the old way (in fact, I think that the new way never worked for me) so I stopped trying to use it):

/etc/init.d/mysql start

Have you tried it? Because it looks like start it isn't starting mysql as ps showed.

  • Yeah I get an error message that says it won't work using that method and I have to use the "service mysql start" – user784637 Jan 3 '12 at 17:41
  • I get a message like that, but it starts anyway. Have you tried ps -ef | grep mysql after /etc/init.d/mysql start. – lafdez Jan 3 '12 at 18:15

just type this code in terminal

sudo opt/lampp/bin/mysql -u root


sudo opt/lampp/bin/mysql -u root -p

if you have set a password.


type this in a terminal

mysql -u root -p

then enter your password

  • I can't, it brings up the same error message as above when I try to do that. – user784637 Jan 3 '12 at 17:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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