Ubuntu – Where is systemd script for thesql.service located

mariadbMySQLsystemdUbuntu

I am actually using MariaDB (drop-in replacement for MySQL).

I'm trying to make some changes to my systemd mysql.service file.

I can see it exists because running sudo systemctl lists it and indicates that it is loaded / active / running.

The issue is that I can't find the file to make edits. From what I've read in various articles I've found is that the doc should be located at

/etc/systemd/system/multi-user.target.wants/mysql.service

But it isn't. I've browsed through other directories at the /etc/systemd level to no avail. Any ideas?

Best Answer

For units defined in static files you could use systemctl status, with the information outputed issuing that command, you will be able to see its location.

For example:

# systemctl  status sshd
● sshd.service - OpenSSH Daemon
   Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset: disabled)
   Active: active (running) since Mon 2016-10-31 17:01:01 UTC; 1 weeks 0 days ago
 Main PID: 283 (sshd)
    Tasks: 1 (limit: 4915)
   CGroup: /system.slice/sshd.service
           └─290 /usr/bin/sshd -D

Note that the tab command could be helpful here.

Therefore, in my system the systemd services are placed under /usr/lib/systemd/. Please, note that there could be folders in that location.

Another way is to use the find command in that specific location to find a service:

# find /usr/lib/systemd/ | grep -i mysql

I hope that helps ;)