4

I'm having trouble restarting mysql. When I enter the following command, I get this message:

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

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

And it hangs forever.

When I try to restart mysql as a service using the following command:

# service mysql restart

It hangs forever.

I can't log into mysql as root anymore either. Any ideas on how to get this running again?

I tried the following

# service mysql start
start: Job is already running: mysql

When I do the following

# ps -ef | grep -i mysql | grep -v grep

Nothing gets returned

  • Please check if your disk is not full – Sergei Jan 2 '12 at 20:29
  • The disk is not full – user784637 Jan 2 '12 at 20:30
  • Did you try a reboot? Maybe hangs the pid file? – Dennis Wisnia Jan 2 '12 at 21:00
  • I already tried rebooting the server. Same problem still – user784637 Jan 2 '12 at 21:05
  • uninstalling and reinstalling mysql worked for me: apt-get remove mysql-server, apt-get autoremove, apt-get install mysql-server – xinthose Jun 13 '17 at 18:25
6

Check the MySQL logs in /var/log or possibly in /var/lib/mysql.

My bet is that the reason it "hangs" is because its doing a repair of some sort on tables that could have gotten corrupted. I've seen "mysql" take 20 minutes or longer to "start"... How long have you given it before assuming it's "hung"?

See if the logs indicate anything. Also, after starting mysql once, try running this to verify MySQL is, in fact, running:

ps aux | grep mysql
| improve this answer | |
  • Thanks for your suggestions, but look at the last line I wrote with the ps -ef, nothing gets returned even after I 'start' mysql – user784637 Jan 2 '12 at 20:51
  • Have you checked the logs? – David W Jan 2 '12 at 20:54
  • Yah, nothing special – user784637 Jan 2 '12 at 20:58
  • Where can I can the mysqld.sock? It's missing from /var/run/mysqld – user784637 Jan 2 '12 at 21:01
3

The best way to debug this type of thing is to directly run

sudo mysqld

That's the only way to see startup errors. (For some reason, they aren't written to any of the mysql logs). Often you can see it's failing to load a binlog or having problems getting to a certain directory.

| improve this answer | |
  • 1
    You sure that sudo belongs there?! – Bobby Jul 11 '12 at 9:20
  • running this without sudo will give you more accurate feedback unless you are launching mysqld as sudo. MySQL has global and user specific settings, so sudo would only give you information for the root user. – Tisch Feb 27 '16 at 15:11

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.