fd03d4f057
When enabling MariaDB (BR2_PACKAGE_MARIADB=y) and systemd (BR2_INIT_SYSTEMD=y) in buildroot, the mysqld.service fail to start with a permission error. See output of command: journalctl --unit=mysqld Which shows: systemd[1]: Starting MySQL database server... install[102]: install: can't create directory '/var/log/mysql': Permission denied systemd[1]: mysqld.service: Control process exited, code=exited, status=1/FAILURE Since the service file includes the "User=mysql" directive, the "ExecStartPre=" is executed as this user, which does not have permission to create a directory in "/var/log". This commit fixes this issue by adding the "!" prefix, which will execute the command with full privileges. See the systemd.service manual page entry for "ExecStart=", table "Special executable prefixes": https://www.freedesktop.org/software/systemd/man/systemd.service.html#ExecStart= or https://github.com/systemd/systemd/blob/v250/man/systemd.service.xml#L339 Moreover, the "mysql_install_db" invocation does not need this special prefix, as the "/var/lib/mysql" directory on target is already owned by the "mysql" user. The "chown" command is also useless and is removed in this commit. Reported-by: Gilles Talis <gilles.talis@gmail.com> Signed-off-by: Julien Olivain <ju.o@free.fr> Tested-By: Gilles Talis <gilles.talis@gmail.com> Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
15 lines
430 B
Desktop File
15 lines
430 B
Desktop File
[Unit]
|
|
Description=MySQL database server
|
|
|
|
[Service]
|
|
ExecStartPre=/bin/sh -c 'test "`ls -1 /var/lib/mysql | wc -l`" != "0" || mysql_install_db --basedir=/usr --datadir=/var/lib/mysql'
|
|
ExecStartPre=!install -d -o mysql -g root -m 0755 /var/log/mysql
|
|
ExecStart=/usr/bin/mysqld_safe --log-error=/var/log/mysql/mysqld.log
|
|
Restart=always
|
|
User=mysql
|
|
RuntimeDirectory=mysql
|
|
RuntimeDirectoryMode=0755
|
|
|
|
[Install]
|
|
WantedBy=multi-user.target
|