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

I install mysql and try start

/usr/local/mysql/bin# ./mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

Any Idea?

share|improve this question

marked as duplicate by Luis Alvarado Jul 10 '13 at 7:35

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

mysql can be started from upstart. Basically you install mysql-server package. You can easily search for mysql-server package in synaptic and install it. You will be prompted for root password during installtion[i.e.mysql user root password] . After that in terminal just do

sudo start mysql


sudo service mysql start

Mysql usually is started on boot so you may have it running as well.

Just ps aux | grep mysql to see if it is running.

share|improve this answer
Job failed to start and no mysql process running – Pierre de LESPINAY Jul 2 '13 at 8:24

Ubuntu 11.10: sudo dpkg-reconfigure mysql-server-5.1

Ubuntu 12.04: sudo dpkg-reconfigure mysql-server-5.5

Follow instruction then reboot.

This problem may happen when you upgrade from one ubuntu version to another and config gets messed up somehow. Usually the related to the startup process of mysql daemon mysqld)

share|improve this answer
Worked for me but deleted my users – Pierre de LESPINAY Jul 2 '13 at 8:29

Change the server name from "localhost" to "" in your connection params, Im sure it will do the trick.

share|improve this answer

I see you are using /tmp/ for the mysql.socket so either you are not installing the mysql 5.1 that comes from ubuntu by default or you are installing mysql 5.5.x (which you need to mention in your question if this is the case). Anyway some of the things you can do are:

  1. Verify that mysql is not already running: ps -e|grep -i 'mysqld' if it appears then kill it. sudo killall -9 mysqld . If it does not die grab the pid from the ps you made here and kill -9 PID

  2. "Try" to run mysql via /etc/init.d/mysql start if it gives you the exact same error from above then you need to copy the mysql.server file from the mysql you downloaded which can be found in the support-files folder inside the mysql folder you downloaded or in the /usr/local/mysql folder and copy it to /etc/init.d/mysql (Example: cp mysql.server /etc/init.d/mysql and give it a executable permission chmod +x /etc/init.d/mysql then run it again.

  3. If it still gives you a problem then edit the config file in /etc/my.cnf (if you have 5.5 installed) or /etc/mysql/mysql.conf (if you have 5.1 installed) and change ALL the /tmp/mysql.socket lines to /var/run/mysqld/mysqld.sock. Note that the config file can also be in /etc/mysql/my.cnf.

    Test this but please ADD what mysql you are using, either 5.1 or 5.5. I mention 5.5 here because 5.5 is the one that uses /tmp and 5.1 uses the default /var/run

If by any change you happen to be using 5.5 then remember to delete the directories of old 5.1 from /etc/mysql, /var/lib/mysql and /user/lib/mysql

share|improve this answer

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