Server Fault is a question and answer site for system and network administrators. 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 am having trouble administering my MySQL. I tried to stop it like this:

/etc/init.d/mysql stop

and I got this message:

Rather than invoking init scripts through /etc/init.d, use the service(8)
utility, e.g. service mysql stop

Since the script you are attempting to invoke has been converted to an
Upstart job, you may also use the stop(8) utility, e.g. stop mysql

So I tried doing this:

$ sudo  mysql stop
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
$ sudo  mysql start
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

My OS is Ubuntu. Any ideas why I seem to be running into this dead end? :)

share|improve this question

migrated from Apr 16 '11 at 23:30

This question came from our site for professional and enthusiast programmers.

Did you try service mysql stop ? – ypercubeᵀᴹ Apr 16 '11 at 0:07
@ypercube $ service mysql stop stop: Unknown instance – Genadinik Apr 16 '11 at 0:09
up vote 2 down vote accepted

You need superuser rights to run service:

$ sudo service mysql stop

or (as root):

# service mysql stop

Using the service and chkconfig utilities is now the defacto standard for service initscript handling on most Linux distributions.


If none of the above works, you can try mysqladmin directly:

$ sudo mysqladmin shutdown
share|improve this answer
@thkala the "sudo service mysql stop" command gave this error message: "stop: Unknown instance:" – Genadinik Apr 16 '11 at 0:20
@Genadinik: Have you tried sudo mysqladmin shutdown directly? – thkala Apr 16 '11 at 0:26

Read that message again.

...use the service(8) utility, e.g. service mysql stop may also use the stop(8) utility, e.g. stop mysql

You're mixing the two together, which ends up running the mysql command-line client and trying to connect to the stop and `start databases on the local server (which apparently isn't running).

Pick one or the other. Note that either one will need sudo in front of it if you're not logged in as root.

And, in case it wasn't obvious, mysql-server needs to be installed correctly for any of this to work. It's starting to sound like something's a bit borked about your install.

share|improve this answer
@chao in both cases it tells me that it is an unknown utility. Where should I run it from? The directory I am doing this in is /var/run – Genadinik Apr 16 '11 at 0:12
It doesn't matter where you run it from; it works everywhere, as long as you're root (and of course, have the MySQL server installed). – cHao Apr 16 '11 at 0:14

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.