How to Upgrade and Install MariaDB 10.7/10.6 on Ubuntu 20.04 LTS and 18.04 LTS

In this tutorial we’ll upgrade/install to Mariadb 10.7/10.6 on Ubuntu 20.04 LTS, 18.04 LTS. MariaDB is designed as a drop-in replacement of MySQL with more features, new storage engines, fewer bugs, and better performance. MariaDB is developed by many of the original developers of MySQL who now work for the MariaDB Foundation and the MariaDB Corporation, and by many people in the community. To upgrade follow this simple steps to upgrade it to latest version.

Login as root and follow the commands one by one.

Backup is not necessary but I always recommend to backup your dbs

please note you can’t downgrade from major version to 10.x minor version

First Add mariadb apt repository :

To upgrade to Mariadb 10.7

For 20.04 LTS :

sudo apt-get install software-properties-common dirmngr apt-transport-https
sudo apt-key adv --fetch-keys 'https://mariadb.org/mariadb_release_signing_key.asc'
sudo add-apt-repository 'deb [arch=amd64,arm64,ppc64el,s390x] https://mirror.rackspace.com/mariadb/repo/10.7/ubuntu focal main'  

For 18.04 LTS :

sudo apt-get install software-properties-common dirmngr apt-transport-https
sudo apt-key adv --fetch-keys 'https://mariadb.org/mariadb_release_signing_key.asc'
sudo add-apt-repository 'deb [arch=amd64,arm64,ppc64el] https://mirror.rackspace.com/mariadb/repo/10.7/ubuntu bionic main'  

To upgrade to Mariadb 10.6

For 20.04 LTS :

sudo apt-get install software-properties-common dirmngr apt-transport-https
sudo apt-key adv --fetch-keys 'https://mariadb.org/mariadb_release_signing_key.asc'
sudo add-apt-repository 'deb [arch=amd64,arm64,ppc64el,s390x] https://mirror.rackspace.com/mariadb/repo/10.6/ubuntu focal main'  

For 18.04 LTS :

sudo apt-get install software-properties-common dirmngr apt-transport-https
sudo apt-key adv --fetch-keys 'https://mariadb.org/mariadb_release_signing_key.asc'
sudo add-apt-repository 'deb [arch=amd64,arm64,ppc64el] https://mirror.rackspace.com/mariadb/repo/10.6/ubuntu bionic main'  

If you get : the following signatures couldn’t be verified because the public key is not available: NO_PUBKEY F1656F24C74CD1D8 of something else in place of red marked key just use that key number and replace it below :

apt-key adv --keyserver keyserver.ubuntu.com --recv-keys F1656F24C74CD1D8

To Upgrade :

This is only for the upgrade and follow this commands :-

Stop and remove MySQL server :

service mysql stop
apt remove mysql-client mysql-client-core  mysql-server mysql-server-core mariadb-server
or
apt remove mysql-server mariadb-server

Now we’ll Update/install

apt update
apt install mariadb-server
apt upgrade

When the installer ask for the password just leave it blank it will ask to set the password 3-4 times for all time leave the password blank (imp when upgrading from mysql to mariadb only)

Well Mariadb is now installed and you just need to start mariadb server and upgrade the database :

systemctl enable mariadb
systemctl start mariadb

Now upgrade the database :

mysql_upgrade --force

To Install :

This is only for fresh installation don’t use it for the upgrade.

apt update
apt install mariadb-server
apt upgrade

When it will ask you to enter root password please enter and remember the password, after successful installation start the mariadb server :

systemctl enable mariadb
systemctl start mariadb

That’s it you’re done upgrading mariadb

Back to top button