My name is Stefan Ashwell and when I'm not coding personal projects or painting miniatures, I'm a Software Engineer at Holmes Media in Market Harborough.

This blog is a place for me to write about things that require that little bit extra to solve. We all have gaps in our knowledge and every now and then I need to reach out on search engines or blogs to find an answer. Often, these answers come from multiple sources. This blog serves as a personal resource, but if it's helpful for me I'm sure it'll help others too!

MySql not restarting on Ubuntu

Posted on 10 March 2016

Today I came across an issue with MySql not restarting correctly. In addition, when rebooting the server, MySql would run for a few seconds and then crash, and would not restart after doing so.

It seemed to be down to a rogue MySql process running which was stopping it from starting up again:

lsof -i:3306

Running this command gave the following results:

COMMAND  PID  USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
mysqld  3119 mysql   10u  IPv6  13406      0t0  TCP *:mysql (LISTEN)

So, I killed process 3119:

kill -9 3119

And then restarted again successfully:

sudo /etc/init.d/mysql restart
 * Stopping MySQL database server mysqld                                                            [ OK ]
 * Starting MySQL database server mysqld                                                            [ OK ]
 * Checking for tables which need an upgrade, are corrupt or were not closed cleanly.

Curiously, this happened 2 times, both straight after creating a new subdomain in Plesk. Not sure if it’s related or just a coincidence.