Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I am using MySQL v5.1 on Ubuntu machine.

MySQL on my machine used to work. (Running mysql -u root gave me the MySQL command line.)

This afternoon, I did the following thing:

1. check active process related to 'mysql' by run:

$ ps aux | grep 'mysql'
mysql  1457  3.3  1.3 130044 27076 ?        Ssl  16:22   0:43 /usr/sbin/mysql

2. I saw from above output the PID of the mysql process is 1457, so I killed it with:

$ sudo kill 1457

3. now, if I run $ mysql -u root , I get an error:

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

which is reasonable since I killed the process.

How can I have my MySQL server back up and running again after I killed it?

I tried to run sudo /etc/init.d/mysql start, but my MySQL server does not start. Why is that?

share|improve this question
    
The server process is mysql**d**. If it doesn't restart, you'll need to check the logs (dev.mysql.com/doc/refman/5.1/en/server-logs.html) to see why it isn't starting. Can't help you without more information. BTW, killing database processes is a Bad Idea. –  Mat Nov 30 '11 at 15:15
    
relate to your last line: what is the error message when you are try to start the server ? –  Hanan N. Nov 30 '11 at 16:24
add comment

4 Answers

On Ubuntu you should use service:

sudo service mysql start

And to restart it in the future:

sudo service mysql restart
share|improve this answer
add comment

After some research I found this. You are using Ubuntu, so go to System -> Administration -> Services , uncheck MySQL, save it, and recheck it again.

share|improve this answer
add comment

You've probably corrupted a database to the point mysqld won't start. Consult /var/log/daemon.log for mysql startup errors. Also look for /var/log/mysql.err and see if there is anything there.

In the future "Don't Do That" as unclean database server shutdown will corrupt myisam tables pretty badly and if you're lucky on innodb, just cause a major rollback that wipes all unssuccessful transactions.

You can find error message information on http://dev.mysql.com/doc/

share|improve this answer
add comment

I would use daemontools or such to keep mysql running on the system incase of undesired shutdown of the database servers. However, as everyone else noted here, killing of database servers is really a bad idea in the production environment.

To answer the question of mysql would not start, its because mysql init script checks for the pidfile of the mysqld, I am not sure if it checks for the validity of the pid, and then the stalelock might be stopping mysql to start. Best is to do service mysql restart or /etc/init.d/mysql restart to ensure mysql is starting from base. Ensure that mysql service is running with ps and service mysqld status Also check the logs of mysqld, to check whether there was a clean startup of the process and all the databases/tables were properly initialized.

share|improve this answer
add comment

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.