12

I am running Ubuntu(16.04) with MySQL(5.7). Daily when Ubuntu job(Daily apt upgrade and clean activities) is running, it's stopping MySQL service and I will have to manually restart it. My syslog entries are given below:

May 17 06:53:19 campaygn-production systemd[1]: Starting Daily apt upgrade and clean activities...
May 17 06:53:27 campaygn-production systemd[1]: Reloading.
May 17 06:53:27 campaygn-production systemd[1]: Started ACPI event daemon.
May 17 06:53:27 campaygn-production systemd[1]: Stopping MySQL Community Server...
May 17 06:53:36 campaygn-production systemd[1]: Stopped MySQL Community Server.

How to stop ubuntu to shutdown mysql every-time ?

5
  • 1
    I don't think you should see the problem like "stopping the shutdown of your mysql servce" but more like "restart automatically your mysql service after daily upgrade" – damadam Jun 14 '18 at 7:22
  • yeah, that's what I am looking for, I am not able to find a way to automatically restart MYSQL when it's shutdown by daily upgrade, cuz daily upgrade don't run at a particular time. – Jatin Seth Jun 15 '18 at 7:40
  • can't you add sudo service mysql restart at the end of your script which launch the daily upgrade (if the mysql service is mysql)? – damadam Jun 15 '18 at 8:09
  • Does /etc/mysql/FROZEN exist? – Robie Basak Oct 24 '18 at 17:24
  • @RobieBasak - no, this file does not exist. – Jatin Seth Dec 12 '18 at 9:20
14

I'm not sure it's possible to stop mysql from being killed by the update process. I've had the same problem and I disabled unattended updates entirely so that I can do them on my own schedule (after also testing them in a qa environment). To disable the automatic daily updates entirely:

sudo apt-get remove unattended-upgrades
sudo systemctl stop apt-daily.timer
sudo systemctl disable apt-daily.timer
sudo systemctl disable apt-daily.service
sudo systemctl daemon-reload
1
  • Oh !, I have updated the question, it is, can I stop this behaviour without disable this automatic job ? – Jatin Seth Jun 14 '18 at 7:20
3

I've had this issue occur as well. Mysql stopped for no apparent reason. Upon further investigation of the syslog I found this

systemd[1]: Starting Daily apt upgrade and clean activities...
systemd[1]: Stopping MySQL Community Server...
systemd[1]: Stopped MySQL Community Server.

The way to fix this problem was to use apt-mark hold to stop updates to all packages that have mysql in their name, this way mysql will never shut down for updates. This will, however, stop automatic updates.

Another way to solve this was to make sure the systemd unit for mysql is enabled. In that case it would reboot right back up after the update, so no need to blacklist the package with apt-mark hold.

4
  • "Another way to solve this was to make sure the systemd unit for mysql is enabled" How to check that? apt-mark hold mysql-server seems did not helped :( – Ingus Feb 7 '20 at 8:31
  • @Ingus I think checking can be done with systemctl is-enabled mysql, and in case it is disabled you can run systemctl enable mysql to enable it. This won't stop the updates from shutting down mysql, but will hopefully make mysql start back up again. The case I described is for mysql getting shut down by automatic updates, this shouldn't happen often. What exactly happened in your case? – HelloWorld Feb 9 '20 at 11:23
  • @Ignus apt-mark hold didn't help? You mean you had mysql shut down again the next time ubuntu automatically run updates? – HelloWorld Feb 9 '20 at 11:30
  • ` apt-mark ` did the trick after i used correct package :) – Ingus Feb 9 '20 at 12:58
0

I had this same issue, and the reason was because MySQL was in a frozen state. The file (/etc/mysql/FROZEN) existed which meant that the packages wouldn't fully install. This was caused by mixing Maria and MySQL on the same server. The way I detected it was by just reinstalling the package:

apt-get install --reinstall mysql-server-5.7

This also stopped the service without restarting it, but gives an error when run interactively. Once I fixed the issue, this command succeeded. I did open a bug on launchpad about this.

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.