Here is a cheap, quick and temporary solution to MySQL server has gone away message to ensure that mysql-server is running, that is automatically restarted after failure. This solution should be considered as temporary as it is in your best interest to investigate further your log files why your mysql server stopped and take appropriate steps to find long term solution. In the example below we use Debian Wheezy.

First install puppet:
# wget http://apt.puppetlabs.com/puppetlabs-release-wheezy.deb
# dpkg -i puppetlabs-release-wheezy.deb
# apt-get update
# apt-get install puppet

Create puppet manifest /root/mysql.pp. Feel free to use different location and file name:
# cat /root/mysql.pp
service { 'mysql':
	ensure => running,
}
Next, create a crontab task to run every minute:
# crontab -e
and add following line:
* * * * * /usr/bin/puppet apply /root/mysql.pp
The above will ensure that we check every minute whether mysql-server is running. If it is running we take no action and if its down puppet will start automatically.


Free Linux eBooks

Do you have the right skills?

Our IT Skills Watch page reflects an up to date IT skills demand leaning towards the Linux and Unix environment. We have considered a number of skills and operating systems.

See the result...

Linux Online Training

Learn to run Linux servers and prepare for LPI certification with Linux Academy. 104 available video lessons with PDF course notes with your own server!

Go to top