# MariaDB not starting

**URL:** https://dietpi.com/forum/t/mariadb-not-starting/2950
**Category:** Troubleshooting
**Created:** [14 February 2019 04:11 UTC](https://dietpi.com/forum/t/mariadb-not-starting/2950 "2019-02-14T04:11:39Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![johnvick](https://dietpi.com/forum/user_avatar/dietpi.com/johnvick/32/16_2.png) [@johnvick](https://dietpi.com/forum/u/johnvick)
#### Post date: [14 February 2019 04:11 UTC](https://dietpi.com/forum/t/mariadb-not-starting/2950/1 "2019-02-14T04:11:39Z")

</div>

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/](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’.

---

<div class="post-metadata">

### Author: ![MichaIng](https://dietpi.com/forum/user_avatar/dietpi.com/michaing/32/7_2.png) [@MichaIng](https://dietpi.com/forum/u/MichaIng)
#### Post date: [16 February 2019 17:38 UTC](https://dietpi.com/forum/t/mariadb-not-starting/2950/2 "2019-02-16T17:38:24Z")

</div>

> Can’t create test file /var/lib/mysql/Z83.lower-test

Perhaps a permissions issue?  
chown -R mysql:mysql /var/lib/mysql

---

<div class="post-metadata">

### Author: ![johnvick](https://dietpi.com/forum/user_avatar/dietpi.com/johnvick/32/16_2.png) [@johnvick](https://dietpi.com/forum/u/johnvick)
#### Post date: [16 February 2019 18:35 UTC](https://dietpi.com/forum/t/mariadb-not-starting/2950/3 "2019-02-16T18:35:04Z")

</div>

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/](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’.

---

<div class="post-metadata">

### Author: ![MichaIng](https://dietpi.com/forum/user_avatar/dietpi.com/michaing/32/7_2.png) [@MichaIng](https://dietpi.com/forum/u/MichaIng)
#### Post date: [21 February 2019 21:19 UTC](https://dietpi.com/forum/t/mariadb-not-starting/2950/4 "2019-02-21T21:19:50Z")

</div>

johnvick  
Do you have apparmor installed? [https://dba.stackexchange.com/questions/106085/cant-create-file-var-lib-mysql-user-lower-test](https://dba.stackexchange.com/questions/106085/cant-create-file-var-lib-mysql-user-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 😃.

---

<div class="post-metadata">

### Author: ![johnvick](https://dietpi.com/forum/user_avatar/dietpi.com/johnvick/32/16_2.png) [@johnvick](https://dietpi.com/forum/u/johnvick)
#### Post date: [21 February 2019 23:35 UTC](https://dietpi.com/forum/t/mariadb-not-starting/2950/5 "2019-02-21T23:35:04Z")

</div>

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

---

<div class="post-metadata">

### Author: ![MichaIng](https://dietpi.com/forum/user_avatar/dietpi.com/michaing/32/7_2.png) [@MichaIng](https://dietpi.com/forum/u/MichaIng)
#### Post date: [22 February 2019 00:01 UTC](https://dietpi.com/forum/t/mariadb-not-starting/2950/6 "2019-02-22T00:01:11Z")

</div>

😃 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 😉.

---

<div class="post-metadata">

### Author: ![Backspace](https://dietpi.com/forum/letter_avatar_proxy/v4/letter/b/e19adc/32.png) [@Backspace](https://dietpi.com/forum/u/Backspace)
#### Post date: [14 April 2020 19:37 UTC](https://dietpi.com/forum/t/mariadb-not-starting/2950/7 "2020-04-14T19:37:41Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![johnvick](https://dietpi.com/forum/user_avatar/dietpi.com/johnvick/32/16_2.png) [@johnvick](https://dietpi.com/forum/u/johnvick)
#### Post date: [14 April 2020 20:26 UTC](https://dietpi.com/forum/t/mariadb-not-starting/2950/8 "2020-04-14T20:26:01Z")

</div>

Possibly this:

[https://dietpi.com/forum/t/solved-new-install-6-22-odroid-xu4-mariadb-error/3107/1](https://dietpi.com/forum/t/solved-new-install-6-22-odroid-xu4-mariadb-error/3107/1)

---

<div class="post-metadata">

### Author: ![Joulinar](https://dietpi.com/forum/user_avatar/dietpi.com/joulinar/32/57_2.png) [@Joulinar](https://dietpi.com/forum/u/Joulinar)
#### Post date: [14 April 2020 22:06 UTC](https://dietpi.com/forum/t/mariadb-not-starting/2950/9 "2020-04-14T22:06:55Z")

</div>

sounds more like this [Nextcloud install fail with Mariadb issue · Issue #3465 · MichaIng/DietPi · GitHub](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`

---

<div class="post-metadata">

### Author: ![Backspace](https://dietpi.com/forum/letter_avatar_proxy/v4/letter/b/e19adc/32.png) [@Backspace](https://dietpi.com/forum/u/Backspace)
#### Post date: [21 April 2020 17:21 UTC](https://dietpi.com/forum/t/mariadb-not-starting/2950/10 "2020-04-21T17:21:52Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Joulinar](https://dietpi.com/forum/user_avatar/dietpi.com/joulinar/32/57_2.png) [@Joulinar](https://dietpi.com/forum/u/Joulinar)
#### Post date: [21 April 2020 21:09 UTC](https://dietpi.com/forum/t/mariadb-not-starting/2950/11 "2020-04-21T21:09:25Z")

</div>

ok cool that it is working now after re-formt the drive
