mysql.service location on Ubuntu 18.04 server?
The files in /lib/systemd/system should not be edited by the admin directly and should be left as they are. Those files belong to an installed package and updates and/or changes could break things.
To modify existing systemd
files and configuration like the .service
files, systemd
provides the /etc/systemd/system path, which overrides files and settings found in /lib/systemd/system.
So, if you e.g. have two .service
files as follows,
/etc/systemd/system/mysql.service
/lib/systemd/system/mysql.service
the one located at /etc/systemd/system/mysql.service will be used when entering commands like systemctl [start|stop|enable|disable] mysql.service
.
Additionally, systemd
provides drop-in ".d" directories which allows to just change or add a single option of the .service
file in /lib/systemd/system. You can use systemctl edit mysql.service
to create such a drop-in .d directory.
All you need to enter then is the section (e.g. [Service]
, [Unit]
, ... ) and the option you want to change.
Since you want to change the restart behaviour, do a systemctl edit mysql.service
and enter the lines as follows.
[Service]
Restart=on-failure
This will create a folder
/etc/systemd/system/mysql.service.d
and the override file
/etc/systemd/system/mysql.service.d/override.conf
which contains the lines you entered earlier. You can also manually create the files and folders.
I would prefer this method over copying the whole .service
file, as the package updates bring changes, you only have to take care of the single changes you have altered.
In any case, when working with systemd
and doing changes to configuration files, one has to enter
systemctl daemon-reload
to activate the changes.
Do not change anything else like lxcfs
related things. The multi-user.target.wants
is just an organizational method of systemd
to group services together that shall be started for the multi-user
target. Targets in systemd
replaces the old init 0 1 2 3 4 5 6
method.
Some of the double mysql.service
files, will be symbolic links that point to your actual .service
file.
Please also see the manpages as follows.
man systemctl
man systemd.unit
man systemd.service
man systemd.target