Saturday, December 1, 2007

MySQL fails to start on Gutsy

For some reason, mySql wasn't starting up on my machine. It was easy enough to find the cause just by looking at the log. Apparently there was no /var/run/mysqld directory where mySql could write to. So I created the directory, gave the required permissions and didn't give it a second thought.

Turns out that when I rebooted my computer, mySQL wasn't starting again! The directory wasn't there anymore! Because I don't want to have to create the directory and start mySQL by hand each time the computer restart, here's what I did:

sudo gvim /etc/init.d/mysql

Just after the 'start') string I added the following content:

'start')
# Create directory in /var/run
if [ ! -d "/var/run/mysqld" ]; then
mkdir /var/run/mysqld
chown mysql.mysql /var/run/mysqld
fi
# All done