Skip to content
Advertisement

Ownership of datadir is reset to mysql:mysql after every reboot

I’m using MariaDB 10.5.9-1 on Manjaro 5.10.23-1.

I initialized mariadb database directory using this command:

JavaScript

After data directory initialization, permissions and ownership of /var/lib/mysql:

JavaScript

And there’s one another directory /run/mysqld, which file mysqld.sock resides in by default when server is up and running, has permissions and ownership:

JavaScript

I have no idea when /run/mysqld was created, maybe the first time server started successfully.

mysqld_safe --datadir=/var/lib/mysql can start server successfully.

But the problem is, after every reboot, the permissions and ownership of /var/lib/mysql and /run/mysqld was reset to mysql:mysql :

JavaScript

Thus due to various “permission denied”, MariaDB server failed to start.

There’s one question totally the same as mine.

Here is full output of systemctl cat mariadb.service.

Advertisement

Answer

I’m not sure why you changed the user. It may not be a good idea. But assuming there is a good reason, below explains your situtation:

It looks like the mysqld_safe may have changed the permissions. If you start this way for testing add --user=shaouai to the arguments.

To allow systemd to default start as the user shaouai

systemctl edit mariadb.service

Add:

JavaScript

Then:

JavaScript

Then systemctl restart mariadb.service.

This will start the service as this user instead of the default mysql user.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement