MariaDB not starting Topic is solved

Having issues with your DietPi installation, or, found a bug? Post it here.
User avatar
johnvick
Legend
Posts: 693
Joined: Wed Jun 08, 2016 11:53 am
Location: New Zealand

MariaDB not starting

Post by johnvick »

This is the message - any ideas on how to fix? Uninstall/reinstall didn't help.

Feb 14 17:08:11 Z83 systemd[1]: Starting MariaDB 10.1.37 database server...
Feb 14 17:08:12 Z83 mysqld[1684]: 2019-02-14 17:08:12 140339973317056 [Note] /us
r/sbin/mysqld (mysqld 10.1.37-MariaDB-0+deb9u1) starting as process 1684 ...
Feb 14 17:08:12 Z83 mysqld[1684]: 2019-02-14 17:08:12 140339973317056 [Warning]
Can't create test file /var/lib/mysql/Z83.lower-test
Feb 14 17:08:12 Z83 systemd[1]: mariadb.service: Main process exited, code=exited, status=1/FAILURE
Feb 14 17:08:12 Z83 systemd[1]: Failed to start MariaDB 10.1.37 database server.
Feb 14 17:08:12 Z83 systemd[1]: mariadb.service: Unit entered failed state.
Feb 14 17:08:12 Z83 systemd[1]: mariadb.service: Failed with result 'exit-code'.
root@Z83:~# systemctl status mariadb.service
● mariadb.service - MariaDB 10.1.37 database server
Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Thu 2019-02-14 17:08:12 NZDT; 42s ago
Docs: man:mysqld(8)
https://mariadb.com/kb/en/library/systemd/
Process: 1684 ExecStart=/usr/sbin/mysqld $MYSQLD_OPTS $_WSREP_NEW_CLUSTER $_WSREP_START_POSITION (code=exited, status=1/FAILURE)
Process: 1607 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= || VAR=`/usr/bin/galera_recovery`; [ $? -eq 0 ] && systemctl set-environmen
t _WSREP_START_POSITION=$VAR || exit 1 (code=exited, status=0/SUCCESS)
Process: 1603 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
Process: 1600 ExecStartPre=/usr/bin/install -m 755 -o mysql -g root -d /var/run/mysqld (code=exited, status=0/SUCCESS)
Main PID: 1684 (code=exited, status=1/FAILURE)
Status: "MariaDB server is down"

Feb 14 17:08:11 Z83 systemd[1]: Starting MariaDB 10.1.37 database server...
Feb 14 17:08:12 Z83 mysqld[1684]: 2019-02-14 17:08:12 140339973317056 [Note] /usr/sbin/mysqld (mysqld 10.1.37-MariaDB-0+deb9u1) starting as process 1684 ...
Feb 14 17:08:12 Z83 mysqld[1684]: 2019-02-14 17:08:12 140339973317056 [Warning] Can't create test file /var/lib/mysql/Z83.lower-test
Feb 14 17:08:12 Z83 systemd[1]: mariadb.service: Main process exited, code=exited, status=1/FAILURE
Feb 14 17:08:12 Z83 systemd[1]: Failed to start MariaDB 10.1.37 database server.
Feb 14 17:08:12 Z83 systemd[1]: mariadb.service: Unit entered failed state.
Feb 14 17:08:12 Z83 systemd[1]: mariadb.service: Failed with result 'exit-code'.
User avatar
MichaIng
Site Admin
Posts: 2423
Joined: Sat Nov 18, 2017 6:21 pm

Re: MariaDB not starting

Post by MichaIng »

Can't create test file /var/lib/mysql/Z83.lower-test
Perhaps a permissions issue?
chown -R mysql:mysql /var/lib/mysql
User avatar
johnvick
Legend
Posts: 693
Joined: Wed Jun 08, 2016 11:53 am
Location: New Zealand

Re: MariaDB not starting

Post by johnvick »

Thanks MichaIng but this is the result:

root@Z83:~# systemctl status mariadb.service
● mariadb.service - MariaDB 10.1.37 database server
Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Sun 2019-02-17 07:32:39 NZDT; 12s ago
Docs: man:mysqld(8)
https://mariadb.com/kb/en/library/systemd/
Process: 1082 ExecStart=/usr/sbin/mysqld $MYSQLD_OPTS $_WSREP_NEW_CLUSTER $_WSREP_START_POSITION (code=exited, status=1/FAILURE)
Process: 1005 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= || VAR=`/usr/bin/galera_recovery`; [ $? -eq 0 ] && systemctl set-environment _
WSREP_START_POSITION=$VAR || exit 1 (code=exited, status=0/SUCCESS)
Process: 1000 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
Process: 997 ExecStartPre=/usr/bin/install -m 755 -o mysql -g root -d /var/run/mysqld (code=exited, status=0/SUCCESS)
Main PID: 1082 (code=exited, status=1/FAILURE)
Status: "MariaDB server is down"

Feb 17 07:32:37 Z83 systemd[1]: Starting MariaDB 10.1.37 database server...
Feb 17 07:32:39 Z83 mysqld[1082]: 2019-02-17 7:32:39 140082421084608 [Note] /usr/sbin/mysqld (mysqld 10.1.37-MariaDB-0+deb9u1) starting as process 1082 ...
Feb 17 07:32:39 Z83 mysqld[1082]: 2019-02-17 7:32:39 140082421084608 [Warning] Can't create test file /var/lib/mysql/Z83.lower-test
Feb 17 07:32:39 Z83 mysqld[1082]: [90B blob data]
Feb 17 07:32:39 Z83 mysqld[1082]: 2019-02-17 7:32:39 140082421084608 [ERROR] Aborting
Feb 17 07:32:39 Z83 systemd[1]: mariadb.service: Main process exited, code=exited, status=1/FAILURE
Feb 17 07:32:39 Z83 systemd[1]: Failed to start MariaDB 10.1.37 database server.
Feb 17 07:32:39 Z83 systemd[1]: mariadb.service: Unit entered failed state.
Feb 17 07:32:39 Z83 systemd[1]: mariadb.service: Failed with result 'exit-code'.
User avatar
MichaIng
Site Admin
Posts: 2423
Joined: Sat Nov 18, 2017 6:21 pm

Re: MariaDB not starting

Post by MichaIng »

@johnvick
Do you have apparmor installed? https://dba.stackexchange.com/questions ... lower-test

We place a symlink to /var/lib/mysql to link it to /mnt/dietpi_userdata/mysql to easily allow database files on external drive.
However in case of apparmor the actual mysql dir location needs to be added with write permissions to the related apparmor config and perhaps it does not allow the symlink at all. Note 100% sure currently based on the link above.
In case a bind mount seems to be the workaround, but I think we need to do some changes to the MariaDB installer then to not remove the database on reinstall.

In another case SELinux was the issue, so basically similar :D.
User avatar
johnvick
Legend
Posts: 693
Joined: Wed Jun 08, 2016 11:53 am
Location: New Zealand

Re: MariaDB not starting

Post by johnvick »

I'm pretty sure I don't have apparmor installed. /etc/appmor.d containf a fil with a few comments only.

I don't think I need mariadb on this device anyway so I'll take it out, it must be a leftover some something I did before.

John
User avatar
MichaIng
Site Admin
Posts: 2423
Joined: Sat Nov 18, 2017 6:21 pm

Re: MariaDB not starting

Post by MichaIng »

:D Okay. Perhaps check out the content of /var/lib/mysql/, as the database names (directory names inside) could give you some hint which software uses/used it ;).
Backspace
Posts: 2
Joined: Tue Apr 14, 2020 9:19 pm

Re: MariaDB not starting

Post by Backspace »

Greetings, I'm writing in this topic because I've been stumbling against a related issue recently.

While trying to move dietpi_userdata to an external and self-powered hard drive with `dietpi-drive_manager`, mariadb service couldn't restart.

The output of `ls -al /var/lib` shows that `/var/lib/mysql -> /mnt/dietpi_userdata/mysql`

The output of `ls -al /mnt` shows that `/mnt/dietpi_userdata -> /mnt/datastore/dietpi_userdata`

The owner of /mnt/datastore/dietpi_userdata/mysql is mysql:mysql

Yet trying to restart the mariadb service multiple times kept showing the same error :
[Warning] Can't create test file /var/lib/mysql/DietPi.lower-test

I've tried to :
  • change symlink from /mnt/dietpi_userdata/mysql to /mnt/datastore/dietpi_userdata/mysql
  • `mount --bind /mnt/datastore/dietpi_userdata/mysql /var/lib/mysql`
  • take a look at /etc/apparmor.d/usr.sbin.mysqld : it is a file with a long comment telling that the file is a placeholder
My attempts have been unsuccessful. I'm moving my dietpi_userdata directory to my SD card for now, but I would love to be able to have it set for good in my external hard drive.

I'm using a Rock64 with a Nextcloud instance on it.
User avatar
johnvick
Legend
Posts: 693
Joined: Wed Jun 08, 2016 11:53 am
Location: New Zealand

Re: MariaDB not starting

Post by johnvick »

User avatar
Joulinar
Posts: 2597
Joined: Sat Nov 16, 2019 12:49 am

Re: MariaDB not starting

Post by Joulinar »

sounds more like this https://github.com/MichaIng/DietPi/issues/3465

there user mysql was not able to write to the external device, doesn't matter what we tried. Looks like issue was cause due to an incomplete format process that was performed on this device. At the end we tried with a different device which went successful.

btw, this is correct if you moved /mnt/dietpi_userdata/ to an external device
The output of `ls -al /var/lib` shows that `/var/lib/mysql -> /mnt/dietpi_userdata/mysql`

The output of `ls -al /mnt` shows that `/mnt/dietpi_userdata -> /mnt/datastore/dietpi_userdata`
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
Backspace
Posts: 2
Joined: Tue Apr 14, 2020 9:19 pm

Re: MariaDB not starting

Post by Backspace »

The external drive was an NTFS formatted drive with proprietary stuff from Seagate ; I formatted the drive with dietpi-drive_manager and the process went (mostly) fine then. I don't have the issue anymore, MariaDB and Nextcloud work with my dietpi_userdata directory on my external hard drive.
Post Reply