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?
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:
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 ;)
The default location for systemd init script is:
But the preferred way to modify them is to create a custom script in:
scripts in the latter folder override the script in the former location.
In your particular case it's probably because MySQL doesn't have a systemd service file, but only a SystemV init script in
/etc/init.d/mysql
. You do have to usesystemctl
orservice
to control it though. Running/etc/init.d/mysql stop
makes systemd thinks it crashed and restarts it.Not sure if the newer Ubuntu's do this too, but older ones definitely.
On Ubuntu you can find it at
I once tried to run the command systemctl enable mysql.service, but found that it searches for the file at /etc/systemd/system/ (where usually there's a hard link for it there) and in my case there was no mysql.service file there. So I created a hard link with:
I use ubuntu 16.04! after modifing /etc/security/limit.conf and /etc/mysql/my.cnf, then run
sudo systemctl edit mysql.service
adding following lines
[Service]
LimitNOFILE=infinity
systemd
According to the official documentation for systemd on the maria.db site, the configuration files for the maria.db service are stored here:
systemd quick info:
...and for the configuration file we have:
If your installation is using a customized configuration file to start the maria.db service, then you might find the script in this location:
Where XXXX can be any file name!
This could be because of the recommendation made in the above mentioned link:
In the feedback to the online article there is a short comment that points out that:
This leads me to the conclusion that you might still have to search for the init.d variants of the configuration files (as pointed out in my initial version of this post) to pinpoint your issues.
init.d
I would check the directory
/etc/init.d
for the existence of a mysql or mariadb file.If you then open up the corresponding file (e.g. mysql on my Ubuntu Server) you can find the startup part.
(note: no mysqld file, just a plain mysql file)
At some point you will find the sanity checks in the service startup script:
So the actual file for my setup would be the /etc/mysql/my.cnf file. Then go from there.
Your configuration may differ, but equipped with this knowledge you should be able to find the configuration file for your service.
More generically, to find a file by its name you can use one of the following approach:
find / -iname "<filename>"
updatedb && locate <filename>
Here is how I found on my Ubuntu 16