How to fix MariaDB unmet Dependencies on Ubuntu 20.04

One client server had MariaDB 15 installed somehow, then they ask me to troubleshooting the problem them fixed that problem. Their application expected MariaDB 10.4 because this error “General error: 1615 Prepared statement needs to be re-prepared

I add repository from official, when installing the mariadb-server using APT I got the following error

apt install mariadb-server -y

the errors

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
 mariadb-server : Depends: mariadb-server-10.4 (>= 1:10.4.16+maria~focal) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

Fix The Problem

To fix the problem remove the different version of MySQL/MariaDB, check using

dpkg -l | grep -E 'mysql|mariadb'

dpkg error server mariadb
that due to the conflict between 2 versions of Mariadb, mysql-common 10.5.7 installed by I want to install mariadb-server 10.4, first remove these file

apt purge mysql-common

apt purge mysql ubuntu

if the error still appear, remove the mysql folder, before executing this rememmber to backup the folder

# backup the file
# cp -r /etc/mysql /var/lib/mysql ~/
# remove everyting
rm -rf /etc/mysql /var/lib/mysql

the last step is to install mariadb-server again

apt install mariadb-server

apt install mariadb again

Leave a Comment