MichaIng / DietPi

Lightweight justice for your single-board computer!
https://dietpi.com/
GNU General Public License v2.0
4.9k stars 499 forks source link

Unable to uninstall MariaDB due to service failing #4436

Open psbankar opened 3 years ago

psbankar commented 3 years ago

Details:

MichaIng commented 3 years ago

Many thanks for your report.

Indeed, at least when the mysqldump command is still available (hence the MariaDB server package was not removed yet), we create a backup. It's meant to protect against accidents/errors, as the database usually contains the very most important and sensitive software data.

But I see the point and I'm also regularly annoyed when a broken software package cannot be removed just because it is broken. As a workaround, you can use "Change command" and enter ":" or "true" to continue. The following two commands will fail as well but those are not error-handled. As we already show a dialog before the backup is created, we should indeed turn it into a yes-no choice. Also the service start can be error-handled a way so that one can choose "Ignore" instead of "Exit". So it will be still possible to retry and open a shell to check whats wrong, but the uninstall can be continued regardless. Additionally we could keep the raw database files then, as an alternative backup, not as good as an SQL dump, as it only works with the particular MariaDB version, but better than nothing.

What is actually the reason for MariaDB to fail?

psbankar commented 3 years ago

Thanks for the workaround! It helped me uninstall MariaDB successfully.

What is actually the reason for MariaDB to fail?

No idea actually. My dietpi stopped working suddenly so I flashed it again and restored the backup but everything else worked fine except MariaDB. Tried a lot to recover the DB but nothing worked. Thankfully the DB didn't contain anything important so I can start from scratch.

Joulinar commented 3 years ago

we could troubleshoot the database if you like. Following would be needed

systemctl restart mariadb.service
journalctl -u mariadb
cat /var/log/mysql/error.log
readlink /var/lib/mysql
readlink -f /var/lib/mysql
MichaIng commented 3 years ago

Probably we can get it working, however, MariaDB version and raw database files usually need to match in a certain degree. So for important databases I recommend to regularly do an SQL dump:

mysqldump -A > /path/to/backup.sql

to backup all databases, or

mysqldump specific_database_name > /path/to/backup.sql

to backup a specific database.

These dumps contain the SQL instructions to recreate the databases on different SQL-compatible database systems and definitely multiple MariaDB versions.

psbankar commented 3 years ago

@Joulinar Thanks but I already moved on from recovering it 😁. It was just Home Assistant database so wasn't that important. @MichaIng yes thanks for the suggestion. I will take backups of the database regularly from now on.