MySql stopped and I can't restart it.

December 7, 2013 19.9k views
I received the following error: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (111) So after restarting the server and trying to figure out what was going on I tried reinstalling mysql with this: apt-get install mysql-server Then I restarted apache and still keep getting the same error message. What could be causing this? Can anyone point me in the right direction to trouble shoot this issue? Thanks!
  • I'm having the same issue, 512MB droplet.

    mysql is running and I can log into it.

    I can see all of my tables still so it's not likely someone found an SQL injection attack and my passwords are all the same.

    I have rebooted my droplet.

    total used free shared buffers cached
    Mem: 501868 327452 174416 21180 23376 174676
    -/+ buffers/cache: 129400 372468
    Swap: 0 0 0

    Filesystem 1K-blocks Used Available Use% Mounted on
    /dev/vda 20509308 7145252 12299200 37% /
    none 4 0 4 0% /sys/fs/cgroup
    udev 240132 4 240128 1% /dev
    tmpfs 50188 312 49876 1% /run
    none 5120 0 5120 0% /run/lock
    none 250932 0 250932 0% /run/shm
    none 102400 0 102400 0% /run/user

    As you can see, despite the small droplet there is tons of RAM and disk space.

    What gives?

    [EDIT] Okay it seems like my mysql server started responding after I wrote this. Random...

  • Same problem I have found with 512 plan. You can view it

  • Log in as super user or use sudo
    Open /etc/mysql/my.cnf using gedit
    Find bind-address, and change its value to the database server host machine's IP address. For me, it was localhost or
    Save and close the file.
    Come back to terminal and execute sudo service mysql start

    And it worked for me.

12 Answers
It's a 2gb droplet and I did reboot. In case anyone else runs into this situation I checked the logs and didn't see anything that would indicate a problem. I reinstalled MySql, rebooted the droplet and updated apache. I couldn't find anything that would be causing MySql to not work. I finally ended up taking a snapshot of the droplet, creating a new droplet from that snapshot image and adding the DNS info to the new droplet IP for all the sites on the old droplet. Then I restarted the new droplet and everything was fixed and working properly.
It means that mysql is not running. Try checking its error logs and seeing why it's crashing:
tail /var/log/mysql.err
Here's what I can find but I have no idea what could be causing the error:

131207 8:46:33 [Note] /usr/sbin/mysqld: Normal shutdown

131207 8:46:33 [Note] Event Scheduler: Purging the queue. 0 events
131207 8:46:33 InnoDB: Starting shutdown...
131207 8:46:35 InnoDB: Shutdown completed; log sequence number 6625970
131207 8:46:35 [Note] /usr/sbin/mysqld: Shutdown complete

131207 8:46:35 [Note] Plugin 'FEDERATED' is disabled.
131207 8:46:35 InnoDB: The InnoDB memory heap is disabled
131207 8:46:35 InnoDB: Mutexes and rw_locks use GCC atomic builtins
131207 8:46:35 InnoDB: Compressed tables use zlib
131207 8:46:35 InnoDB: Initializing buffer pool, size = 128.0M
131207 8:46:35 InnoDB: Completed initialization of buffer pool
131207 8:46:35 InnoDB: highest supported file format is Barracuda.
131207 8:46:35 InnoDB: Waiting for the background threads to start
131207 8:46:36 InnoDB: 5.5.31 started; log sequence number 6625970
131207 8:46:36 [Note] Server hostname (bind-address): ''; port: 3306
131207 8:46:36 [Note] - '' resolves to '';
131207 8:46:36 [Note] Server socket created on IP: ''.
131207 8:46:36 [Note] Event Scheduler: Loaded 0 events
131207 8:46:36 [Note] /usr/sbin/mysqld: ready for connections.
Version: '5.5.31-0ubuntu0.12.04.2' socket: '/var/run/mysqld/mysqld.sock' port: 3306 (Ubuntu)
131207 9:35:03 [Note] /usr/sbin/mysqld: Normal shutdown

131207 9:35:03 [Note] Event Scheduler: Purging the queue. 0 events
131207 9:35:03 InnoDB: Starting shutdown...
131207 9:35:04 InnoDB: Shutdown completed; log sequence number 6764201
131207 9:35:04 [Note] /usr/sbin/mysqld: Shutdown complete
Try rebooting your droplet:
sudo reboot
It's a 2gb droplet and I have rebooted.

This my website : Chu Doanh Nghiep
Me too, ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (111)

I was trying reboot, because mysql not running

I have a new droplet and experienced this both times I shut it down. I just tried entering the console and inputting sudo service mysql restart. For me, this worked immediately.

Hi, same problem here and if I restart mysql, it would FAIL. Everything looks fine after reboot, however this happens frequently. Does anyone know how this happens?

  • thanks kama, I guess it's out of memory... Isn't 512M memory enough to run a blog on CentOS?

  • @kindpire There are a lot of different factors that come into play when considering the memory requirements for MySql. Unfortunately, many WordPress plugins authors don't prioritize performance. I'd start with an audit of the plugins you're using. Either way, adding a swap file to your server should help by giving to some wiggle room when it comes to memory usage. Check out: How To Add Swap on CentOS 7

    One of the easiest ways to make your server more responsive, and guard against out-of-memory errors in your application, is to add some swap space. This gives you the ability to increase the amount of information that your server can keep in its working memory. In this guide, we will cover how to create and enable a swap file on a CentOS 7 server.
  • @asb Hi, thanks for quick reply! Yes, I guess the problems should be in my MySQL (MariaDB) setting. Each time, once I installed a new plugin, it would crash. After reboot the whole machine, everything goes fine again.

Same problem here using 512 plan, you can view media creeks

Killed 5 hours trying to figure out what causes the error. The solution was stupid simple, I just needed to free up some disk space on my droplet. I had a few huge log files that had eaten up all the free space so mysql simply couldn't start and gave me the ERROR 2002 (HY000). Check how much free space you have by doing *df -h * command in terminal.

Have another answer? Share your knowledge.