MariaDB error Topic is solved

Having issues with your DietPi installation or found a bug? Post it here.
Zeuskk
Posts: 11
Joined: Sun Feb 07, 2021 11:20 am

Re: MariaDB error

Post by Zeuskk »

Running uninstaller from inside dietpi-software gave me this error:

Code: Select all

 DietPi-Software
─────────────────────────────────────────────────────
 Mode: Uninstalling MariaDB: database

[FAILED] DietPi-Software | systemctl start mariadb
[FAILED] DietPi-Software | systemctl start mariadb

Code: Select all

│  - Command: systemctl start mariadb                                          │
│  - Exit code: 1                                                              │
│  - DietPi version: v7.0.2 (MichaIng/master) | HW_MODEL: 4 | HW_ARCH: 2 |     │
│ DISTRO: 5                                                                    │
│  - Image creator: DietPi Core Team                                           │
│  - Pre-image: Raspbian Lite                                                  │
│  - Error log:                                                                │
│ Job for mariadb.service failed because the control process exited with error │
│ code.                                                                        │
│ See "systemctl status mariadb.service" and "journalctl -xe" for details.     │
│                                                                              │
│     Retry          : Re-run the last command that failed                     │
│     DietPi-Config  : Edit network, APT/NTP mirror settings etc               │
│     Open subshell  : Open a subshell to investigate or solve the issue       │
│     Send report    : Uploads bugreport containing system info to DietPi      │
│                    ●─ Devs only ──────────────────────────────────────●      │
│     Change command : Adjust and rerun the command  
And systemctl status mariadb.service gave me:

Code: Select all

root@DietPi:~# systemctl status mariadb.service
● mariadb.service - MariaDB 10.3.27 database server
   Loaded: loaded (/lib/systemd/system/mariadb.service; disabled; vendor preset: enabled)
  Drop-In: /etc/systemd/system/mariadb.service.d
           └─dietpi-services_edit.conf
   Active: failed (Result: exit-code) since Wed 2021-03-03 09:52:56 CET; 2min 25s ago
     Docs: man:mysqld(8)
           https://mariadb.com/kb/en/library/systemd/
  Process: 20412 ExecStartPre=/usr/bin/install -m 755 -o mysql -g root -d /var/run/mysqld (code=exited, status=0/SUCCESS)
  Process: 20413 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
  Process: 20415 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: 20472 ExecStart=/usr/sbin/mysqld $MYSQLD_OPTS $_WSREP_NEW_CLUSTER $_WSREP_START_POSITION (code=exited, status=1/FAILURE)
 Main PID: 20472 (code=exited, status=1/FAILURE)
   Status: "MariaDB server is down"

mar 03 09:52:54 DietPi systemd[1]: Starting MariaDB 10.3.27 database server...
mar 03 09:52:54 DietPi mysqld[20472]: 2021-03-03  9:52:54 0 [Note] /usr/sbin/mysqld (mysqld 10.3.27-MariaDB-0+deb10u1) starting as process 20472 ...
mar 03 09:52:54 DietPi mysqld[20472]: 2021-03-03  9:52:54 0 [Warning] Could not increase number of max_open_files to more than 16384 (request: 32186)
mar 03 09:52:54 DietPi mysqld[20472]: 2021-03-03  9:52:54 0 [Warning] Can't create test file /var/lib/mysql/DietPi.lower-test
mar 03 09:52:56 DietPi systemd[1]: mariadb.service: Main process exited, code=exited, status=1/FAILURE
mar 03 09:52:56 DietPi systemd[1]: mariadb.service: Failed with result 'exit-code'.
mar 03 09:52:56 DietPi systemd[1]: Failed to start MariaDB 10.3.27 database server.

I don't know if this is important but I have system installed on external SSD, but I never moved manually any userdata files, folders etc. Just installed system on SSD with uasp enabled without any problems and is working on it for months.
User avatar
Joulinar
Posts: 5149
Joined: Sat Nov 16, 2019 12:49 am

Re: MariaDB error

Post by Joulinar »

ah yes, sorry, DietPi is trying to start MariaDB before it goes to remove the packages

let's try it manually

Code: Select all

G_AGP mariadb-server
rm -Rf /{mnt/dietpi_userdata,var/lib,var/log,etc}/mysql
this should clean the installation of MariaDB. If this was working, you would need to set aSOFTWARE_INSTALL_STATE[88]=0 inside /boot/dietpi/.installed to clear the installation status. Now, you should be able to install MariaDB again.
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
User avatar
MichaIng
Site Admin
Posts: 3106
Joined: Sat Nov 18, 2017 6:21 pm

Re: MariaDB error

Post by MichaIng »

The CLI issue was fixed with: https://github.com/MichaIng/DietPi/comm ... 10eb912271
Changelog: https://github.com/MichaIng/DietPi/comm ... ba4a407530

Many thanks for reporting the issue.

Yeah uninstalling MariaDB is not possible as long as the service cannot start, since it does a database dump. Theoretically we could skip this step, but database content usually is the very most sensible and important data for any software title, so I'd like to keep this step as a measure against accidents. One alternative could be, if the service start fails, to leave the raw database directory in place instead. It is not as good as a database dump, since it cannot easily be imported into any other database server, but with a proper warning it should be fine?

But since you don't use the MariaDB server anymore, the commands suggested by Joulinar are pretty fine to purge it.
Zeuskk
Posts: 11
Joined: Sun Feb 07, 2021 11:20 am

Re: MariaDB error

Post by Zeuskk »

Joulinar wrote: Wed Mar 03, 2021 11:25 am ah yes, sorry, DietPi is trying to start MariaDB before it goes to remove the packages

let's try it manually

Code: Select all

G_AGP mariadb-server
rm -Rf /{mnt/dietpi_userdata,var/lib,var/log,etc}/mysql
this should clean the installation of MariaDB. If this was working, you would need to set aSOFTWARE_INSTALL_STATE[88]=0 inside /boot/dietpi/.installed to clear the installation status. Now, you should be able to install MariaDB again.
Strange think is after that commands MariaDB service still exist, dietpi-services shows it on list as 'failed' service. Rebooting system doesn't help.
Or maybe MariaDB and MariaDB Service are two different things? :x

Pushing dietpi-software install 88 give me:

Code: Select all

[  OK  ] DietPi-Software | Initialised database
[  OK  ] DietPi-Software | Reading database

 DietPi-Software
─────────────────────────────────────────────────────
 Mode: Automated install

[  OK  ] DietPi-Software | Installing MariaDB: database
[  OK  ] DietPi-Software | Free space check: path=/ | available=76757 MiB | required=500 MiB
[  OK  ] DietPi-Software | DietPi-Userdata validation: /mnt/dietpi_userdata
[  OK  ] DietPi-Software | Checking network connectivity
[  OK  ] DietPi-Software | Checking DNS resolver
[  OK  ] Network time sync | Completed
[ SUB1 ] DietPi-Services > unmask
[  OK  ] DietPi-Services | unmask : proftpd
[  OK  ] DietPi-Services | unmask : redis-server
[  OK  ] DietPi-Services | unmask : mariadb
[  OK  ] DietPi-Services | unmask : php7.3-fpm
[  OK  ] DietPi-Services | unmask : lighttpd
[  OK  ] DietPi-Services | unmask : transmission-daemon
[  OK  ] DietPi-Services | unmask : plexmediaserver
[  OK  ] DietPi-Services | unmask : jackett
[  OK  ] DietPi-Services | unmask : sonarr
[  OK  ] DietPi-Services | unmask : radarr
[  OK  ] DietPi-Services | unmask : bazarr
[  OK  ] DietPi-Services | unmask : docker
[  OK  ] DietPi-Services | unmask : cron
[ SUB1 ] DietPi-Services > stop
[  OK  ] DietPi-Services | stop : cron
[  OK  ] DietPi-Services | stop : docker
[  OK  ] DietPi-Services | stop : bazarr
[  OK  ] DietPi-Services | stop : radarr
[  OK  ] DietPi-Services | stop : sonarr
[  OK  ] DietPi-Services | stop : jackett
[  OK  ] DietPi-Services | stop : plexmediaserver
[  OK  ] DietPi-Services | stop : transmission-daemon
[  OK  ] DietPi-Services | stop : lighttpd
[  OK  ] DietPi-Services | stop : php7.3-fpm
[  OK  ] DietPi-Services | stop : mariadb
[  OK  ] DietPi-Services | stop : redis-server
[  OK  ] DietPi-Services | stop : proftpd
[  OK  ] DietPi-Software | mkdir -p /mnt/dietpi_userdata/Music /mnt/dietpi_userdata/Pictures /mnt/dietpi_userdata/Video /mnt/dietpi_userdata/downloads /var/www /opt
[  OK  ] DietPi-Software | chown dietpi:dietpi /mnt/dietpi_userdata/Music /mnt/dietpi_userdata/Pictures /mnt/dietpi_userdata/Video /mnt/dietpi_userdata/downloads
[  OK  ] DietPi-Software | chmod 775 /mnt/dietpi_userdata/Music /mnt/dietpi_userdata/Pictures /mnt/dietpi_userdata/Video /mnt/dietpi_userdata/downloads
[ INFO ] DietPi-Software | APT update, please wait...
Hit:1 http://raspbian.raspberrypi.org/raspbian buster InRelease
Hit:2 https://download.docker.com/linux/raspbian buster InRelease
Hit:3 https://downloads.plex.tv/repo/deb public InRelease
Hit:4 https://download.mono-project.com/repo/debian stable-buster InRelease
Hit:5 https://download.mono-project.com/repo/debian raspbianbuster InRelease
Ign:6 https://mediaarea.net/repo/deb/raspbian buster InRelease
Hit:7 https://mediaarea.net/repo/deb/raspbian buster Release
Hit:8 https://archive.raspberrypi.org/debian buster InRelease
Hit:9 https://apt.sonarr.tv/debian buster InRelease
Reading package lists...
[  OK  ] DietPi-Software | APT update

 DietPi-Software
─────────────────────────────────────────────────────
 Mode: Checking for prerequisite software

[ SUB1 ] DietPi-Services > stop
[  OK  ] DietPi-Services | stop : cron
[  OK  ] DietPi-Services | stop : docker
[  OK  ] DietPi-Services | stop : bazarr
[  OK  ] DietPi-Services | stop : radarr
[  OK  ] DietPi-Services | stop : sonarr
[  OK  ] DietPi-Services | stop : jackett
[  OK  ] DietPi-Services | stop : plexmediaserver
[  OK  ] DietPi-Services | stop : transmission-daemon
[  OK  ] DietPi-Services | stop : lighttpd
[  OK  ] DietPi-Services | stop : php7.3-fpm
[  OK  ] DietPi-Services | stop : mariadb
[  OK  ] DietPi-Services | stop : redis-server
[  OK  ] DietPi-Services | stop : proftpd

 DietPi-Software
─────────────────────────────────────────────────────
 Mode: Installing MariaDB: database

[ INFO ] DietPi-Software | Preparing database directory at: /mnt/dietpi_userdata/mysql
[  OK  ] DietPi-Software | rm -f /mnt/dietpi_userdata/mysql
[  OK  ] DietPi-Software | mkdir -p /mnt/dietpi_userdata/mysql
[  OK  ] DietPi-Software | rm -Rf /var/lib/mysql
[  OK  ] DietPi-Software | ln -s /mnt/dietpi_userdata/mysql /var/lib/mysql
[ INFO ] DietPi-Software | APT install for: mariadb-server php7.3-mysql, please wait...
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package mariadb-server.
(Reading database ... 64322 files and directories currently installed.)
Preparing to unpack .../mariadb-server_1%3a10.3.27-0+deb10u1_all.deb ...
Unpacking mariadb-server (1:10.3.27-0+deb10u1) ...
Setting up mariadb-server (1:10.3.27-0+deb10u1) ...
[  OK  ] DietPi-Software | APT install for: mariadb-server php7.3-mysql
[ SUB1 ] DietPi-Services > stop
[  OK  ] DietPi-Services | stop : cron
[  OK  ] DietPi-Services | stop : docker
[  OK  ] DietPi-Services | stop : bazarr
[  OK  ] DietPi-Services | stop : radarr
[  OK  ] DietPi-Services | stop : sonarr
[  OK  ] DietPi-Services | stop : jackett
[  OK  ] DietPi-Services | stop : plexmediaserver
[  OK  ] DietPi-Services | stop : transmission-daemon
[  OK  ] DietPi-Services | stop : lighttpd
[  OK  ] DietPi-Services | stop : php7.3-fpm
[  OK  ] DietPi-Services | stop : mariadb
[  OK  ] DietPi-Services | stop : redis-server
[  OK  ] DietPi-Services | stop : proftpd

 DietPi-Software
─────────────────────────────────────────────────────
 Mode: Configuring MariaDB: database

[ INFO ] DietPi-Software | Assuring 4-byte support and InnoDB Barracuda file format with large prefix
/boot/dietpi/dietpi-software: line 7683: /etc/mysql/mariadb.conf.d/99-dietpi-4byte.cnf: No such file or directory
sed: can't read /etc/mysql/mariadb.conf.d/99-dietpi-4byte.cnf: No such file or directory
sed: can't read /etc/mysql/mariadb.conf.d/99-dietpi-4byte.cnf: No such file or directory
[ SUB1 ] DietPi-Services > dietpi_controlled
[  OK  ] DietPi-Services | dietpi_controlled : proftpd
[  OK  ] DietPi-Services | dietpi_controlled : redis-server
[  OK  ] DietPi-Services | dietpi_controlled : mariadb
[  OK  ] DietPi-Services | dietpi_controlled : php7.3-fpm
[  OK  ] DietPi-Services | dietpi_controlled : lighttpd
[  OK  ] DietPi-Services | dietpi_controlled : transmission-daemon
[  OK  ] DietPi-Services | dietpi_controlled : plexmediaserver
[  OK  ] DietPi-Services | dietpi_controlled : jackett
[  OK  ] DietPi-Services | dietpi_controlled : sonarr
[  OK  ] DietPi-Services | dietpi_controlled : radarr
[  OK  ] DietPi-Services | dietpi_controlled : bazarr
[  OK  ] DietPi-Services | dietpi_controlled : docker
[  OK  ] DietPi-Services | dietpi_controlled : cron
[ SUB1 ] DietPi-Set_hardware > headless (disable)
[  OK  ] DietPi-Set_hardware | Desired setting in /boot/dietpi.txt was already set: AUTO_SETUP_HEADLESS=0
[  OK  ] headless disable | Completed
[  OK  ] DietPi-Survey | Sending survey data

 DietPi-Software
─────────────────────────────────────────────────────
 Mode: Installation completed

[ SUB1 ] DietPi-Services > restart
[  OK  ] DietPi-Services | restart : proftpd
[  OK  ] DietPi-Services | restart : redis-server
[FAILED] DietPi-Services | restart : mariadb
[  OK  ] DietPi-Services | restart : php7.3-fpm
[  OK  ] DietPi-Services | restart : lighttpd
[  OK  ] DietPi-Services | restart : transmission-daemon
[  OK  ] DietPi-Services | restart : plexmediaserver
[  OK  ] DietPi-Services | restart : jackett
[  OK  ] DietPi-Services | restart : sonarr
[  OK  ] DietPi-Services | restart : radarr
[  OK  ] DietPi-Services | restart : bazarr
[  OK  ] DietPi-Services | restart : docker
[  OK  ] DietPi-Services | restart : cron

Dietpi-Services still unmask and stop mariadb that shouldnt really exist. And after all I receive failed mariadb service :(
MichaIng wrote: Wed Mar 03, 2021 3:37 pm The CLI issue was fixed with: https://github.com/MichaIng/DietPi/comm ... 10eb912271
Changelog: https://github.com/MichaIng/DietPi/comm ... ba4a407530

Many thanks for reporting the issue.

Yeah uninstalling MariaDB is not possible as long as the service cannot start, since it does a database dump. Theoretically we could skip this step, but database content usually is the very most sensible and important data for any software title, so I'd like to keep this step as a measure against accidents. One alternative could be, if the service start fails, to leave the raw database directory in place instead. It is not as good as a database dump, since it cannot easily be imported into any other database server, but with a proper warning it should be fine?

But since you don't use the MariaDB server anymore, the commands suggested by Joulinar are pretty fine to purge it.
Hi @MichaIng, I'm glad that I could somehow help with finding this issue and thank you so much for mentioning me in changelog :o :D Still learning stuff so this is kind of new for me.
As you see I still have some problems and I'm not sure if I should maybe reinstall whole system and start from zero, because this looks like I messed up something and somehow at some point and now I'm wasting your time.
Could you tell me for what would I even need MariaDB? It is needed only for Nextcloud in my situation? Tbh I want to install in near future Nextcloud again after I finish setting up HA Supervisor in Docker.
User avatar
Joulinar
Posts: 5149
Joined: Sat Nov 16, 2019 12:49 am

Re: MariaDB error

Post by Joulinar »

looking to your services, it seems MariaDB is used on NextCloud only. Before going to kill you system and start from scratch, one last try to setup the database :)

Code: Select all

G_AGP mariadb-server
G_AGA
rm -Rf /{mnt/dietpi_userdata,var/lib,var/log,etc}/mysql
mkdir /mnt/dietpi_userdata/mysql
ln -s /mnt/dietpi_userdata/mysql /var/lib/mysql
apt install mariadb-server
systemctl status mariadb
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
User avatar
MichaIng
Site Admin
Posts: 3106
Joined: Sat Nov 18, 2017 6:21 pm

Re: MariaDB error

Post by MichaIng »

Yes, like in the other issue, purging the actual MariaDB server packages was missing (hence the still active service). "mariadb-server" is just a dummy package that pulls in mariadb-server-10.3, the actual server package on Debian/Raspbian Buster.

But installing it again is not necessary if Nextcloud is not used anymore? Or just to do a clean uninstall of both?
Otherwise, to remove all traces manually, after the packages have been purged and autopurged (G_AGA):

Code: Select all

rm -Rf /var/www/nextcloud /mnt/dietpi_userdata/nextcloud_data
rm -Rf /{mnt/dietpi_userdata,var/lib,var/log,etc}/mysql
sed -i '/aSOFTWARE_INSTALL_STATE\[88\]/c\aSOFTWARE_INSTALL_STATE\[88\]=0' /boot/dietpi/.installed
sed -i '/aSOFTWARE_INSTALL_STATE\[114\]/c\aSOFTWARE_INSTALL_STATE\[114\]=0' /boot/dietpi/.installed
Zeuskk
Posts: 11
Joined: Sun Feb 07, 2021 11:20 am

Re: MariaDB error

Post by Zeuskk »

MichaIng wrote: Thu Mar 04, 2021 3:37 pm Yes, like in the other issue, purging the actual MariaDB server packages was missing (hence the still active service). "mariadb-server" is just a dummy package that pulls in mariadb-server-10.3, the actual server package on Debian/Raspbian Buster.

But installing it again is not necessary if Nextcloud is not used anymore? Or just to do a clean uninstall of both?
Otherwise, to remove all traces manually, after the packages have been purged and autopurged (G_AGA):

Code: Select all

rm -Rf /var/www/nextcloud /mnt/dietpi_userdata/nextcloud_data
rm -Rf /{mnt/dietpi_userdata,var/lib,var/log,etc}/mysql
sed -i '/aSOFTWARE_INSTALL_STATE\[88\]/c\aSOFTWARE_INSTALL_STATE\[88\]=0' /boot/dietpi/.installed
sed -i '/aSOFTWARE_INSTALL_STATE\[114\]/c\aSOFTWARE_INSTALL_STATE\[114\]=0' /boot/dietpi/.installed
Yesss, this finally helped me :) I get rid of MariaDB and Failed service status. Now system is prepared for future clean Nextcloud install (I hope so haha ;) ). Thank you very much @MichaIng and @Joulinar for help and sorry for late replay. Cheers!
User avatar
Joulinar
Posts: 5149
Joined: Sat Nov 16, 2019 12:49 am

Re: MariaDB error

Post by Joulinar »

ok perfect that it is working now
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
Post Reply