Skip to main content
Topic: [SOLVED] Setup MariaDB under s6 (Read 140 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

[SOLVED] Setup MariaDB under s6

I have been searching how to setup MariaDB with s6, but so far found nothing. Is this possible? There are instructions on how to set it up under OpenRC, but not s6. TIA

Re: Setup MariaDB under s6

Reply #1
The mysql-s6 script should work with mariadb as well. Other than using the init script, there shouldn't be any difference at all when configuring/setting up mariadb.

Re: Setup MariaDB under s6

Reply #2
What am I doing wrong here? I copied the contents of /etc/s6/sv/mysqld to /etc/s6/sv/mariadbd and changed the file /etc/s6/sv/mariadbd/run as follows:
Code: [Select]
#!/usr/bin/execlineb -P
foreground { mkdir -p /run/mariadbd }
foreground { chown mysql:mysql /run/mariadbd }
fdmove -c 2 1
exec mariadbd --user=mysql
Now, when I execute:
Code: [Select]
$  s6-rc-compile /etc/s6/rc/compiled-$(date +%s) /etc/s6/sv/mariadbd
I get the message:
Code: [Select]
s6-rc-compile: warning: source /etc/s6/sv/mariadbd is empty

Re: Setup MariaDB under s6

Reply #3
So, after almost rendering my system unusable I managed to get it back up. It seems that mysqld is the mariadb service, no? I added it to default bundle by
Code: [Select]
$ s6-rc-bundle-update add default mysqld
but unfortunately I need to set up root password. Now, I was able to remove it again from default bundle:
Code: [Select]
$ s6-rc-bundle-update delete default mysqld
but when I do
Code: [Select]
$ ps aux | grep mysql
root       259  0.0  0.0   2784   912 ?        S    19:43   0:00 s6-supervise mysqld
root      5849  0.0  0.0   9472  2236 pts/0    S+   20:11   0:00 grep --colour=auto mysql

This state persists after reboot. How can I stop mysql service so I can set mariadb root password?

P.S:
Code: [Select]
$ for bundle in $(s6-rc-db list bundles); do s6-rc-db contents $bundle | grep mysql; done
returns nothing, meaning that no bundle is calling mysqld?!

Re: Setup MariaDB under s6

Reply #4
Right I meant that the mysqld script works with mariadb as well (the daemon name is exactly the same). To bring a service down, you should use the s6-rc command. See the wiki entry for some more details.

If you had removed mysql from the default bundle, then of course that command will not return anything.

Re: Setup MariaDB under s6

Reply #5
Well, I managed to solve the problem by uninstalling mysqld-s6 and mariadb, then installing mariadb package. Apparently, the initial setup is done manually.  -_-

Code: [Select]
$ mariadb-install-db --user=mysql --basedir=/usr --datadir=/var/lib/mysql
and so on... all of this is written to console during setup. -_-

Re: Setup MariaDB under s6

Reply #6
Well, unfortunately, it still doesn't work, even after I did all the steps indicated during the installation of mariadb. I am therefore reopening this.

I want to have a password for user root. For that, before I install mysqld-s6, I run
Code: [Select]
# mysqld_safe --skip-grant-tables --skip-networking &
# mysql -u root
> flush privileges;
> ALTER USER 'root'@'localhost' IDENTIFIED BY 'pass123abc';
> flush privileges;
where "pass123abc" is my password. After that, I can test this with mysql -u root -p and it works fine without error. But after I pkill mysqld_safe and install mysqld-s6, even after reboot, I'm getting (as root):
Code: [Select]
# mysql -u root -p
Enter password:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/run/mysqld/mysqld.sock' (2)
By the way, there is no need to add mysqld to default bundle in s6, because somehow it automagically still gets started, as indicated in previous posts. (Edit: See my last post.)
Code: [Select]
# ls /run
acpid.socket   crond.pid    dhcpcd       initramfs    lock         lvmpolld.pid  nscd                     service        syslog-ng.pid  udev           utmp
agetty.reload  cron.reboot  elogind.pid  lightdm      lvm          mount         s6-rc                    sudo           systemd        uncaught-logs
connman-vpn    dbus         httpd        lightdm.pid  lvmetad.pid  named         s6-rc:s6-rc-init:goL8Cg  syslog-ng.ctl  tmpfiles.d     user
# ls /var/run
acpid.socket   crond.pid    dhcpcd       initramfs    lock         lvmpolld.pid  nscd                     service        syslog-ng.pid  udev           utmp
agetty.reload  cron.reboot  elogind.pid  lightdm      lvm          mount         s6-rc                    sudo           systemd        uncaught-logs
connman-vpn    dbus         httpd        lightdm.pid  lvmetad.pid  named         s6-rc:s6-rc-init:goL8Cg  syslog-ng.ctl  tmpfiles.d     user
# ps aux | grep mysql
root       255  0.0  0.0   2784   900 ?        S    22:06   0:00 s6-supervise mysqld
root      2600  0.0  0.0   9472  2228 pts/0    S+   22:13   0:00 grep --colour=auto mysql
Code: [Select]
# /etc/my.cnf
#
# This group is read both by the client and the server
# use it for options that affect everything
#
[client-server]

#
# include *.cnf from the config directory
#
!includedir /etc/my.cnf.d

Re: Setup MariaDB under s6

Reply #7
@Dudemanguy  Sorry to bother you, but do you know what could be the cause of mysqld not creating a socket in /run? How can I check where is mysqld run from (by s6-supervise, apparently) and instruct it to create a socket?

Re: Setup MariaDB under s6

Reply #8
mysqld isn't running. s6-supervise is the process supervisor not the actual daemon. You need to either start it manually with s6-rc or add it to the default bundle.

Re: Setup MariaDB under s6

Reply #9
Thanks! That's it, even though mysqld itself wasn't starting, the s6-supervise mysqld still did, which was confusing me. Marking this as solved.

To clarify for people arriving here by future web search, you do need to start mysqld by s6-rc or
Code: [Select]
$ s6-rc-bundle-update add default mysqld
to make it permanent.