Systemd Mysql won't stop

After upgrading to 15.04, I have had lots of fun getting to know systemd. I think I have everything working except I am unable to stop mysql.service; the systemctl command just hangs and mysql just keeps on running. Has anyone else experienced this or might know what's going on?


I had the same problem (upgrade to 15.04, using official files and config).

I had to make the following changes to be able to stop the mysql daemon manually with sytemctl and automatically on system reboot/shutdown:

  1. Make /etc/mysql/debian.cnf readable for the mysql user with

    sudo chgrp mysql /etc/mysql/debian.cnf; sudo chmod 640 /etc/mysql/debian.cnf
    
  2. Provide a slightly modified mysql.service file:

    sudo cp /lib/systemd/system/mysql.service /etc/systemd/system/
    sudo chmod 755 /etc/systemd/system/mysql.service
    
  3. Provide an explicit stop command by opening the copied file in an editor:

    sudo nano /etc/systemd/system/mysql.service
    

    and adding the following line under the [Service] section:

    ExecStop=/usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf shutdown
    

    In Nano, use Ctrl+O to save (Linux way!), Ctrl+X to exit.

  4. Make the new service file known to system:

    sudo systemctl daemon-reload
    

I had the same problem with Ubuntu 15.10 Desktop and I found way to fix it:

log_error parameter in /etc/mysql/mysql.conf.d/mysqld.cnf was commented out. After uncommenting the parameter, systemd does mysqld shutdown without problems.