MariaDB - not starting - after reinstall

Details:

  • Date | 2024-12-29 11:37:55
  • Program name | DietPi-Software
  • Command | systemctl restart mariadb
  • Exit code | 1
  • DietPi version | v9.9.0 (MichaIng/master)
  • Distro version | bookworm (ID=7,RASPBIAN=0)
  • Kernel version | Linux DietPi 6.6.62+rpt-rpi-2712 #1 SMP PREEMPT Debian 1:6.6.62-1+rpt1 (2024-11-25) aarch64 GNU/Linux
  • Architecture | arm64
  • Hardware model | RPi 5 Model B (aarch64) (ID=5)
  • Power supply used | Beseus 100w PD
  • SD card used | SanDisk Extreme 128Gb + Samsung Evo 970 + Data X8200Pro

Steps to reproduce:

Just installing NextCloud (or MariaDB)

Extra details:

  • margerfs installed and working (marging 2 SSDs in 1 storage)
  • nextcloud was installed just after first boot (never tested! ), but because of syncthing β€œissue” I uninstalled it

Additional logs:

Warning: The unit file, source configuration file or drop-ins of mariadb.service changed on disk. Run 'systemctl daemon-reload' to reload units.
Job for mariadb.service failed because the control process exited with error code.
See "systemctl status mariadb.service" and "journalctl -xeu mariadb.service" for details.

systemctl status mariadb.service

Γ— mariadb.service - MariaDB 10.11.6 database server
     Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; preset: enabled)
    Drop-In: /etc/systemd/system/mariadb.service.d
             └─dietpi.conf
     Active: failed (Result: exit-code) since Sun 2024-12-29 12:35:31 GMT; 5min ago
       Docs: man:mariadbd(8)
             https://mariadb.com/kb/en/library/systemd/
    Process: 9142 ExecStartPre=/usr/bin/install -m 755 -o mysql -g root -d /var/run/mysqld (code=exited, status=0/SUCCESS)
    Process: 9143 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
    Process: 9145 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= ||   VAR=`cd /usr/bin/..; /usr/bin/galera_recovery`; [ $? -eq 0 ]   && systemctl set-environment _WSREP_START_POSITION=$VAR || exit 1 (code=exited, status=0/SUCCESS)
    Process: 9174 ExecStart=/usr/sbin/mariadbd $MYSQLD_OPTS $_WSREP_NEW_CLUSTER $_WSREP_START_POSITION (code=exited, status=1/FAILURE)
   Main PID: 9174 (code=exited, status=1/FAILURE)
     Status: "MariaDB server is down"
        CPU: 90ms

Dec 29 12:35:31 DietPi systemd[1]: Starting mariadb.service - MariaDB 10.11.6 database server...
Dec 29 12:35:31 DietPi mariadbd[9174]: 2024-12-29 12:35:31 0 [Warning] Can't create test file '/var/lib/mysql/DietPi.lower-test' (Errcode: 13 "Permission denied")
Dec 29 12:35:31 DietPi mariadbd[9174]: [92B blob data]
Dec 29 12:35:31 DietPi mariadbd[9174]: 2024-12-29 12:35:31 0 [ERROR] Aborting
Dec 29 12:35:31 DietPi systemd[1]: mariadb.service: Main process exited, code=exited, status=1/FAILURE
Dec 29 12:35:31 DietPi systemd[1]: mariadb.service: Failed with result 'exit-code'.
Dec 29 12:35:31 DietPi systemd[1]: Failed to start mariadb.service - MariaDB 10.11.6 database server. 

journalctl -xeu mariadb.service

Dec 29 12:35:31 DietPi mariadbd[9174]: 2024-12-29 12:35:31 0 [Warning] Can't create test file '/var/lib/mysql/DietPi.lower-test' (Errcode: 13 "Permission denied")
Dec 29 12:35:31 DietPi mariadbd[9174]: [92B blob data]
Dec 29 12:35:31 DietPi mariadbd[9174]: 2024-12-29 12:35:31 0 [ERROR] Aborting
Dec 29 12:35:31 DietPi systemd[1]: mariadb.service: Main process exited, code=exited, status=1/FAILURE
β–‘β–‘ Subject: Unit process exited
β–‘β–‘ Defined-By: systemd
β–‘β–‘ Support: https://www.debian.org/support
β–‘β–‘
β–‘β–‘ An ExecStart= process belonging to unit mariadb.service has exited.
β–‘β–‘
β–‘β–‘ The process' exit code is 'exited' and its exit status is 1.
Dec 29 12:35:31 DietPi systemd[1]: mariadb.service: Failed with result 'exit-code'.
β–‘β–‘ Subject: Unit failed
β–‘β–‘ Defined-By: systemd
β–‘β–‘ Support: https://www.debian.org/support
β–‘β–‘
β–‘β–‘ The unit mariadb.service has entered the 'failed' state with result 'exit-code'.
Dec 29 12:35:31 DietPi systemd[1]: Failed to start mariadb.service - MariaDB 10.11.6 database server.
β–‘β–‘ Subject: A start job for unit mariadb.service has failed
β–‘β–‘ Defined-By: systemd
β–‘β–‘ Support: https://www.debian.org/support
β–‘β–‘
β–‘β–‘ A start job for unit mariadb.service has finished with a failure.
β–‘β–‘
β–‘β–‘ The job identifier is 1985 and the job result is failed.

Did you adjusted the dietpi user data directory? Can you share following

readlink /var/lib/mysql
readlink -f /var/lib/mysql

Did you adjusted the dietpi user data directory?

Yes, i was testing features and and moved directory to ssd, and then move it back to sd - completly forget about that…

readlink /var/lib/mysql

 /mnt/dietpi_userdata/mysql

readlink -f /var/lib/mysql

 /mnt/dietpi_userdata/mysql

Incase needed:

root@DietPi:/# ls -la /var/lib/mysql
lrwxrwxrwx 1 root root 26 Dec 29 11:48 /var/lib/mysql -> /mnt/dietpi_userdata/mysql
root@DietPi:/# ls -la /mnt/dietpi_userdata/mysql
total 110600
drwxr-xr-x 2 mysql  mysql       4096 Dec 29 11:31 .
drwxrwxr-x 9 dietpi dietpi      4096 Dec 29 11:31 ..
-rw-r--r-- 1 root   root           0 Dec 29 11:31 debian-10.11.flag
-rw-rw---- 1 mysql  mysql  100663296 Dec 29 11:31 ib_logfile0
-rw-rw---- 1 mysql  mysql   12582912 Dec 29 11:31 ibdata1

How did you move the folder? Using drive manager or manually?

To double check, can you run following

sudo -u mysql -g mysql touch /var/lib/mysql/demo.file
ls -la /mnt/dietpi_userdata/mysql

This should create a demo file to verify databases user access.

How did you move the folder? Using drive manager or manually?

With drive menager

root@DietPi:/# sudo -u mysql -g mysql touch /var/lib/mysql/demo.file
ls -la /mnt/dietpi_userdata/mysql
touch: cannot touch '/var/lib/mysql/demo.file': Permission denied
total 110600
drwxr-xr-x 2 mysql  mysql       4096 Dec 29 11:31 .
drwxrwxr-x 9 dietpi dietpi      4096 Dec 29 11:31 ..
-rw-r--r-- 1 root   root           0 Dec 29 11:31 debian-10.11.flag
-rw-rw---- 1 mysql  mysql  100663296 Dec 29 11:31 ib_logfile0
-rw-rw---- 1 mysql  mysql   12582912 Dec 29 11:31 ibdata1

What about the following. This certainly won’t work either, will it?

sudo -u mysql -g mysql touch /mnt/dietpi_userdata/mysql/demo.file
ls -la /mnt/dietpi_userdata/mysql
root@DietPi:/# sudo -u mysql -g mysql touch /mnt/dietpi_userdata/mysql/demo.file
ls -la /mnt/dietpi_userdata/mysql
touch: cannot touch '/mnt/dietpi_userdata/mysql/demo.file': Permission denied
total 110600
drwxr-xr-x 2 mysql  mysql       4096 Dec 29 11:31 .
drwxrwxr-x 9 dietpi dietpi      4096 Dec 29 11:31 ..
-rw-r--r-- 1 root   root           0 Dec 29 11:31 debian-10.11.flag
-rw-rw---- 1 mysql  mysql  100663296 Dec 29 11:31 ib_logfile0
-rw-rw---- 1 mysql  mysql   12582912 Dec 29 11:31 ibdata1

Nope

Ok let’s check all permissions along the way.

ls -la /mnt/ /mnt/dietpi_userdata/ /mnt/dietpi_userdata/mysql
root@DietPi:/# ls -la /mnt/ /mnt/dietpi_userdata/ /mnt/dietpi_userdata/mysql
/mnt/:
total 40
drwxrwx--- 10 root   root   4096 Dec 29 12:07 .
drwxr-xr-x 18 root   root   4096 Dec 23 18:46 ..
drwxrwxr-x  9 dietpi dietpi 4096 Dec 29 11:31 dietpi_userdata
drwxrwxr-x  2 dietpi dietpi 4096 Dec 23 18:44 ftp_client
drwxrwxr-x  2 dietpi dietpi 4096 Dec 23 18:45 nfs_client
drwxrwxr-x  2 dietpi dietpi 4096 Dec 23 18:45 samba
drwxrwx---  2 root   root   4096 Dec 28 15:55 storage1
drwxrwx---  3 root   root   4096 Dec 28 14:26 storage2
drwxrwx---  2 root   root   4096 Dec 28 13:22 storage3
drwxrwx---  2 root   root   4096 Dec 28 15:55 storage_main

/mnt/dietpi_userdata/:
total 36
drwxrwxr-x  9 dietpi   dietpi   4096 Dec 29 11:31 .
drwxrwx--- 10 root     root     4096 Dec 29 12:07 ..
drwxrwxr-x  2 dietpi   dietpi   4096 Dec 28 10:23 Music
drwxrwxr-x  2 dietpi   dietpi   4096 Dec 28 10:23 Pictures
drwxrwxr-x  2 dietpi   dietpi   4096 Dec 28 10:23 Video
drwxrwxr-x  2 dietpi   dietpi   4096 Dec 28 10:23 downloads
drwxr-xr-x  2 mysql    mysql    4096 Dec 29 11:31 mysql
drwxrwx---  5 www-data www-data 4096 Dec 28 10:31 nextcloud_data
drwx------  3 dietpi   dietpi   4096 Dec 29 10:38 syncthing

/mnt/dietpi_userdata/mysql:
total 110600
drwxr-xr-x 2 mysql  mysql       4096 Dec 29 11:31 .
drwxrwxr-x 9 dietpi dietpi      4096 Dec 29 11:31 ..
-rw-r--r-- 1 root   root           0 Dec 29 11:31 debian-10.11.flag
-rw-rw---- 1 mysql  mysql  100663296 Dec 29 11:31 ib_logfile0
-rw-rw---- 1 mysql  mysql   12582912 Dec 29 11:31 ibdata1

That’s it. It appears that you have adjusted the authorisations to /mnt. The read authorisation for everyone is missing. Did you change that? Instead, write permissions have been added for the group. Therefore the MariaDB user cannot access the folders under /mnt.

To fix

chmod 775 /mnt/
systemctl restart mariadb
systemctl status mariadb

It appears that you have adjusted the authorisations to /mnt

Hmm, hard me to say - maybe one of commands I ran to make margerfs work had some chmod changes…

unfotunelty, still have error:

root@DietPi:~# chmod 775 /mnt/
systemctl restart mariadb
systemctl status mariadb
Job for mariadb.service failed because the control process exited with error code.
See "systemctl status mariadb.service" and "journalctl -xeu mariadb.service" for details.
Γ— mariadb.service - MariaDB 10.11.6 database server
     Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; preset: enabled)
    Drop-In: /etc/systemd/system/mariadb.service.d
             └─dietpi.conf
     Active: failed (Result: exit-code) since Sun 2024-12-29 14:20:09 GMT; 12ms ago
       Docs: man:mariadbd(8)
             https://mariadb.com/kb/en/library/systemd/
    Process: 8993 ExecStartPre=/usr/bin/install -m 755 -o mysql -g root -d /var/run/mysqld (code=exited, status=0/SUCCESS)
    Process: 8994 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
    Process: 8996 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= ||   VAR=`cd /usr/bin/..; /usr/bin/galera_recovery`; [ $? -eq 0 ]   && systemctl set-environment _WSREP_START_POSITION=$VAR || exit 1 (code=exited, status=0/SUCCESS)
    Process: 9025 ExecStart=/usr/sbin/mariadbd $MYSQLD_OPTS $_WSREP_NEW_CLUSTER $_WSREP_START_POSITION (code=exited, status=1/FAILURE)
   Main PID: 9025 (code=exited, status=1/FAILURE)
     Status: "MariaDB server is down"
        CPU: 133ms

Dec 29 14:20:09 DietPi mariadbd[9025]: 2024-12-29 14:20:09 0 [ERROR] Could not open mysql.plugin table: "Table 'mysql.plugin' doesn't exist". Some plugins may be not loaded
Dec 29 14:20:09 DietPi mariadbd[9025]: 2024-12-29 14:20:09 0 [Warning] You need to use --log-bin to make --expire-logs-days or --binlog-expire-logs-seconds work.
Dec 29 14:20:09 DietPi mariadbd[9025]: 2024-12-29 14:20:09 0 [Note] InnoDB: Buffer pool(s) load completed at 241229 14:20:09
Dec 29 14:20:09 DietPi mariadbd[9025]: 2024-12-29 14:20:09 0 [ERROR] Can't open and lock privilege tables: Table 'mysql.servers' doesn't exist
Dec 29 14:20:09 DietPi mariadbd[9025]: 2024-12-29 14:20:09 0 [Note] Server socket created on IP: '127.0.0.1'.
Dec 29 14:20:09 DietPi mariadbd[9025]: 2024-12-29 14:20:09 0 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.db' doesn't exist
Dec 29 14:20:09 DietPi mariadbd[9025]: 2024-12-29 14:20:09 0 [ERROR] Aborting
Dec 29 14:20:09 DietPi systemd[1]: mariadb.service: Main process exited, code=exited, status=1/FAILURE
Dec 29 14:20:09 DietPi systemd[1]: mariadb.service: Failed with result 'exit-code'.
Dec 29 14:20:09 DietPi systemd[1]: Failed to start mariadb.service - MariaDB 10.11.6 database server.

I was trying to uninstal mariadb with dietpisoftware and have error too

different issue now

Some core tables are missing. Better to remove MariaDB completely and do a fresh installation.

You can skip the error in dietpi-software. There should be an error handling menu. Select change command and replace given command with true

1 Like

OMG yes - THX, big big THX!

Where I can learn all that things?

Simple learning by doing. It is also good to read and understand log files in order to know where the error could lie. A certain understanding of Linux is also an advantage. And as far as DietPi is concerned, there are certainly one or two undocumented functions. That comes over time :wink:

We have one or two users who started from scratch and got to grips with Linux just for the fun of it. And now they are a helpful part of the community.