MariaDB daemon don't start in openrc

Maybe that this is not the right place to ask so, be free to delete or move the topic.

The question is simple: if I install MariaDB in a systemd environment, all is simple, like to drink a glass of water. But in openrc is another story... Installation steps seem to be all right, but when I try to START the daemon (mysql.openrc), after I installed it, nothing work, at least in openrc enviroment (I use openrc usually). The only result is that I get a lot of message: basedir, datadir, pid file: nothing is right.

Somebody know how to do? I cannot continue to jump from openrc to systemd when I need to wrok with MariaDB. Please, don't tell me to read the tutorials cause I know it very well and simply don't work in openrc. :slight_smile:

Have you seen this

1 Like

That happens if you don't watch out for message post install.

mysql-openrc prints a message what you need to set to make it start.

post_install() {
	conf1='basedir = /usr'
	conf2='pid-file = /var/run/mysqld/'
	conf3='user = mysql'
	echo "	==>  $file requires $conf1"
	echo "	==>  $file requires $conf2"
	echo "	==>  $file requires $conf3"

@pystub, @artoo : thanks. I did the correction as in the old forum post and something change.

This is what I did:

sudo pacman -S mysql-openrc
correct /etc/mysql/my.cnf
create the mysql user
sudo mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysql
sudo rc-update add mysql defaul

till here all is fine. Time to start the the service

sudo rc-service mysql start

  • Caching service dependencies ... [ ok ]
  • Checking mysqld configuration for mysql ... [ ok ]
  • Starting mysql ...
  • /run/mysql: creating directory
  • /run/mysql: correcting owner
  • ERROR: mysql failed to start [!!]
    and the process crashed after 40 minutes...

Any help?

@ artoo, I'll modify the message in this way

post_install() {
conf0=' [mysqld]'
conf1='basedir = /usr'
conf2='pid-file = /var/run/mysqld/'
conf3='user = mysql'
echo " ==> add in the $file section $conf0"
echo " ==> $file requires $conf1"
echo " ==> $file requires $conf2"
echo " ==> $file requires $conf3"

Just to make clear, to the user, in which section of the my.cnf must be written that data.


Do do something you do not understand. Don't paste the function somewhere, its the function the mysql-openrc package spits out post install what stuff you need to modify.

@artoo, I was simply modifying the text of the post function. I pressed a wrong key and it was posted before I completed the modification. Sorry, :slight_smile:

Oh, so it does. Gotta pick up the habit of checking details pane after using Pamac.

1 Like

I don't like to quarrel but:

  1. the message written from the post function of mysql.openrc is all but not clear and DON'T specify in which section of my.cnf to add the parameters so, due to the fact that the 99,9% of the users are not programmers, but users, shall be a good idea to spent 5 minutes to modify the post function to display clear instructions and not to continue to think like if all the world is a programmers world

  2. I did exactly what reported in the post of the old forum and I thank you (I must remember me to search also in the old forum...) and the final result is that the mariadb daemon after 40 minutes, as previously reported in my post number 4, crashed with the message

  • ERROR: mysql failed to start [!!]
  1. to avoid any "external influences" I did a second mariadb installation on a new Plasma+openrc Manjaro installed from the scratch: the same result! Ergo: there is something else wrong or the installation instruction are not complete or I don't know

  2. all start correctly without any kind of problems with the systemd version exactly as reported in the tutorial.

Now, I'm not an expert of mariadb, simply a user of mariadb so, if somebody can help me to make it up and running in a Manjaro plasma+openrc environment, I'll be happy, otherwise no problem: delete the thread and I'll find a different solution.

To install and to activate MariaDB in openrc environment, at least for me, has been till now unseccesful. Despite the forum, the tutorial, the wiki, so I've decided to write a resume of the info that I found in Manjaro and Arch wiki/forum.
I describe also some strange behaviours that appear when I try to activate MariaDB daemon in openrc environment (see the configuration that I used for the test).
To avoid any interference I tried to activate MariaDB in a new environment, installed from the scratch, for both openrc and systemd.

The Manjaro environment I used for the test are:
Kernel : 4.10.5-1-MANJARO
Plasma : 5.9.4
Qt : 5.8.0
btrfs : 4.10-1
openrc : 0.24.1-1
systemd: 232.8

To install the environments I used manjaro-architect 0.8.2-1.
Both the environment has been installed with the full option.

The test has been done with the mariadb 10.1.22-1.
mariadb, libmariadbclient, mariadb-clients are automatically installed with the "full" option



With three simple steps, 5 minutes no more, all is up and running.
To activate MariaDB I did:

  1. sudo mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysql

  2. sudo systemctl enable mysqld
    Created symlink /etc/systemd/system/ → /usr/lib/systemd/system/mariadb.service.

  3. sudo systemctl start mysqld

All done!


Things are a little bit more complicated


  1. install mysql-openrc: sudo pacman -S mysql-openrc
  2. edit /etc/mysql/my.cnf: in [mysqld] section add the lines as reported here:
    @pystub ->

port = 3306
socket = /run/mysqld/mysqld.sock
user = mysql # manually added
basedir = /usr # manually added
datadir = /var/lib/mysql # manually added
pid-file = /run/mysql/ # manually added

  1. create mysql user, if its not present this is the result:
    chown: invalid user: ‘mysql’
    Cannot change ownership of the database directories to the 'mysql'
    user. Check that you have the necessary permissions and try again.

  2. modify the /var/lib/mysql ownership from a strange 89:89 (???) to mysql:mysql
    chown mysql:mysql /var/lib/mysql -R

  3. if you are using btrfs (as in Arch wiki) remove the btrfs COW functionality for the mariadb "datadir"
    chattr +C /var/lib/mysql # or the datadir you are using

  4. launch the mysql_install_db
    sudo mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysql

All seems to be fine...

  1. add the daemon and no problem
    sudo rc-update add mysql default

  2. start the daemon
    sudo rc-service mysql start

and the result is:

  • Caching service dependencies ... [ ok ]
  • Checking mysqld configuration for mysql ... [ ok ]
  • Starting mysql ...
  • /run/mysql: creating directory
  • /run/mysql: correcting owner [ !! ]
  • ERROR: mysql failed to start

NO WAY to have mariadb up and running in openrc. I investigated also the Gentoo wiki and I'll try, the next days, to install a Gentoo environment to try to activate mariadb in gentoo+openrc, but its VERY strange what happen.

To activeta mariadb in systemd environment is simple and fast.

In openrc all is more complicated, there isn't a clear howto and all the info you fin around are incomplete.
Its strange cause I never was in a similar situation for any other application.

To try to achieve the goal you have:

  1. to create a user NOT needed in systemd (why?)
  2. to correct the ownership of /var/lib/mysql from 89:89 (which kind of user/group is this?) to mysql:mysql.
  3. to manually add in the [mysqld] section some parameters, the info displayed during the installation step are partial and incomplete (datadir is not included and to add in the [mysqld] section is not specified).

After all this steps, is impossible, at least for me, to activate the mariadb daemon, also starting from a scratch installation.

I wasn't able to find any other useful info out there and I'd like to understand who is using mariadb in openrc which are the steps that she/he did to install and to activate the daemon.

The result is that, when I need to work with mariadb, I must boot with a systemd version: funny, but not so much!

Let me try to shed some light on this.

The MariaDB Arch package source has a systemd specific file to create the user:

If we follow that a mysql user is created with uid 89. To create similar user on OpenRC one could do:

# useradd -d /var/lib/mysql -c "MariaDB" -u 89 -U mysql

However the Arch package source also has a systemd specific file to create a temp run directory:

This could be created under OpenRC as:

# mkdir /run/mysqld -m 0755
# chown -R mysql:mysql /run/mysqld

Then I added the lines in /etc/mysql/my.cnf as specified by the post install message:

port            = 3306
socket          = /run/mysqld/mysqld.sock
user            = mysql                        # manually added
basedir         = /usr                          # manually added
datadir         = /var/lib/mysql            # manually added
pid-file        = /run/mysql/   # manually added

After doing the above I proceded as the Arch wiki said:

# mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysql

Finally I started the service, which worked:

# service mysql start

So the steps in total are:

For initial setup:

# pacman -S mysql-openrc
# useradd -d /var/lib/mysql -c "MariaDB" -u 89 -U mysql
# mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysql
# # edit and add variables in /etc/mysql/my.cnf as specified

For running the service:

# mkdir -p /run/mysqld -m 0755
# chown -R mysql:mysql /run/mysqld
# service mysql start

On my Slackware system it creates the run directory on its own when starting; with Arch / Manjaro this is not so because I think its compiled with the -DWITH_SYSTEMD=yes option:

So the cure for this disease might be a mysql-nosystemd package which does not assume systemd.


For this try editing /etc/conf.d/mysql and reducing the value of the STARTUP_TIMEOUT variable.

@aaditya tomorrow I'll surely try. Now I'm a "little" bit tired, I drove for 800kms, more or less... :slight_smile:

Thanks' for the answer!

@aaditya: to try to install mariadb with you instruction the first step has been to reinstall, from the scratch, a new Plasma+openrc+btrfs minimal environment. I used manjaro-architect, last iso, and the testing repo.
When the base installation has been completed, I installed manually mariadb, libmariadbclient, mariadb-clients.
I didn't do nothing else.

First result (see the attached screenshot), is that the dir /var/lib/mysql is owned from the user 89 group 89. If I do the same with systemd the /var/lib/mysql is owned by mysql:mysql.

I don't think its normal...

Trying to track from where appear that "89", the only file where I was able to discover a 89 is in /usr/lib/sysuser.d/mariadb.conf. The file content is: u mysql 89 "MariaDB" /var/lib/mysql

@aaditya: 3 minutes and all was up and running. I think that your instructions must be written in a dedicated wiki or a tutorial.

Thanks' a lot, finally I can stop to exchange hard disk to work with mariadb :slight_smile:

Now I try also on the installation where the /var/lib/mysql is with permission 89:89; I'm curious to understand...

Added a link to this thread in the wiki,,_an_alternative_to_systemd#MySQL_service_not_working

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.

Forum kindly sponsored by