Update I was able to create the mysqld.service file thanks to using /etc/systemd/system exist as suggested by Robert Longson
Now my problem has changed. When I start the service it fails. I ran
systemctl status mysqld.serviceand here is the output:Loaded: loaded (/etc/systemd/system/mysqld.service; enabled; vendor preset: enabled) Active: failed (Result: exit-code) since Sun 2020-03-29 19:01:25 CDT; 38s ago Docs: man:mysqld(7) Process: 9251 ExecStart=/usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf --daemonize --pid mysqld.service: Service hold-off time over, scheduling restart. mysqld.service: Scheduled restart job, restart counter is at 5. Stopped MySQL Server. mysqld.service: Start request repeated too quickly. mysqld.service: Failed with result 'exit-code'. mysqld.service: Failedto start MySQL Server
I am trying to start MySQL Server 5.7, using systemd, for the first time after installing it. The manual says to create a configuration file in /usr/lib/systemd/system but that sub-directory doesn't exist (I am on Ubuntu 18.04). I am following this guide:
To configure the MySQL installation to work with systemd:
- Add a systemd service unit configuration file with details about the MySQL service. The file is named mysqld.service and is placed in /usr/lib/systemd/system.
shell> cd /usr/lib/systemd/system
shell> touch mysqld.service
shell> chmod 644 mysqld.serviceSince I don't have the 'system' sub-directory of systemd, I just created the mysql.service file directly in /usr/lib/systemd. After following the rest of the instructions, I got to:
shell> systemctl start mysqldbut it failed with:
Failed to enable unit: Unit file mysqld.service does not exist.Would someone please explain what I have done wrong? Thank you.
21 Answer
Service files are actually in /etc/systemd/system rather than /usr/lib/systemd/system
If you want to find out why your service is failing you can either try systemctl status mysqld or for a more complete log look into the journalctl command e.g. journalctl -u mysqld -S today.