[Buildroot] [git commit branch/2019.11.x] package/mariadb: fix permissions of data dir when using systemd

From: Peter Korsgaard <peter@korsgaard.com>
Date: 2020-03-07 21:22:51
Subsystem: the rest · Maintainer: Linus Torvalds

commit: https://git.buildroot.net/buildroot/commit/?id=38f9851485cf111c992293ef7cd91f054e9417c8
branch: https://git.buildroot.net/buildroot/commit/?id=refs/heads/2019.11.x

mysql_install_db is currently called in the systemd unit without
--user=mysql that the sysv script uses. This will generate the initial
database files with root permissions. However, mysqld runs as user mysql
so this will cause problems. We fix this by calling chown instead of
passing the user parameter because an upcoming version bump will fail when
ran this way.

Signed-off-by: Ryan Coe <redacted>
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
(cherry picked from commit add2c2ba2ec0e3fd18b6f6612dda6ab78ea6affd)
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
---
 package/mariadb/mysqld.service | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/package/mariadb/mysqld.service b/package/mariadb/mysqld.service
index cd308310c6..3eaef173e1 100644
--- a/package/mariadb/mysqld.service
+++ b/package/mariadb/mysqld.service
@@ -2,7 +2,7 @@
 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=/bin/sh -c 'test "`ls -1 /var/lib/mysql | wc -l`" != "0" || mysql_install_db --basedir=/usr --datadir=/var/lib/mysql && chown -R mysql:mysql /var/lib/mysql'
 ExecStart=/usr/bin/mysqld_safe
 Restart=always
 User=mysql
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help