Best Virtualmin Tutorials: Replace MySQL with MariaDB on Ubuntu 18.04

Not happy with the MySQL Database Server that got installed when you installed Virtualmin on your Ubuntu 18.04 VPS? Want to replace MySQL with MariaDB on Ubuntu 18.04? If yes then hold your horses and follow the complete tutorial to Migrate from MySQL to MariaDB on Ubuntu 18.04.

If you have just installed Virtualmin by following our tutorial on How to Install Virtualmin on Ubuntu 18.04 and want to replace MySQL with MariaDB then, I would recommend you to strictly follow this tutorial on Migrating Virtaulmin Default MySQL with MariaDB on Ubuntu 18.04


Getting Started: Replace MySQL with MariaDB on Ubuntu 18.04

Let’s get started with the tutorial on how we can replace MySQL with MariaDB on Ubuntu 18.04 with Virtualmin already installed on the VPS. First we should take a look at the steps we need to follow.

  1. Backup All Existing Databases in the MySQL Server
  2. Replace MySQL with MariaDB Server
  3. Restore all the Databases to the MariaDB Server
  4. Securing the MariaDB Server

1. Backup All Existing Databases in the MySQL Server

Let’s start this tutorial on replacing MySQL with MariaDB on Ubuntu 18.04 with Virtualmin already installed by first backing up all the existing databases in the MySQL Server. To back all these existing databases we will use the mysqldump command. Then we will also take a backup of the MySQL configuration file.

I have mentioned the steps you need to follow to backup all the existing databases and the MySQL configuration file below. Follow them to do the same.

i. For this step you will need your MySQL root user password. Once you have the root user password run the following command to backup all the existing MySQL databases to a file.

[email protected]:~# mysqldump --all-databases -u root -p > /home/all.dbs

Now once you enter the password for the root user, this command will backup all databases to a file named all.dbs located in the home directory.

To finalize we will also backup the MySQL Configuration file. Use the command given below to do the same.

[email protected]:~# sudo cp /etc/mysql/my.cnf /home/my.cnf

Once the above steps are completed we are good to go to the next step to migrate from MySQL to MariaDB

Replace MySQL with MariaDB Server

Since we have already backed up all the existing databases and the MySQL Configuration file as well. In this step we will uninstall the MySQL Server and then we will install the latest version of the MariaDB Server.

Before we move further with uninstalling the MySQL server we must stop and remove the apparmor utility as it conflicts with the MariaDB Server. We will start the apparmor service again once we have finished to migrate from MySQL to MariaDB.

i. So let’s start by stopping and removing apparmor service. Follow the command to do the same.

[email protected]:~# sudo systemctl stop apparmor.service && sudo update-rc.d -f apparmor remove

ii. Once we have dealt with apparmor we can now uninstall the MySQL server completely. If it asks to remove all databases choose YES.

[email protected]:~# sudo apt-get remove --purge mysql-server mysql-client mysql-common
[email protected]:~# sudo apt-get autoremove && apt-get autoclean

Since we have uninstalled the MySQL Server now we are ready to add the latest MariaDB repository and then install the latest version of MariaDB.

iii. We will first add the MariaDB 10.5 Repositories to Ubuntu as it the latest stable version of MariaDB.

[email protected]:~# sudo apt-get install software-properties-common
[email protected]:~# sudo apt-key adv --fetch-keys 'https://mariadb.org/mariadb_release_signing_key.asc'
[email protected]:~# sudo add-apt-repository 'deb [arch=amd64,arm64,ppc64el] http://mirrors.piconets.webwerks.in/mariadb-mirror/repo/10.5/ubuntu bionic main'

iv. Since the repositories are in place we are now ready to install MariaDB 10.5 and replace MySQL with MariaDB on Ubuntu 18.04 with Virtualmin installed. Use the below command to install MariaDB 10.5.

[email protected]:~# sudo apt-get install mariadb-server

v. Final step before completing the process to replace MySQL with MariaDB on Ubuntu with Virtualmin installed is to restart the AppArmor Service and set it to defaults again.

[email protected]:~# sudo systemctl start apparmor.service
[email protected]:~# sudo update-rc.d apparmor defaults

So now you have successfully installed MariaDB 10.5 and successfully replaced MySQL with MariaDB with Virtualmin already installed. In the next part of the tutorial, we will move on to restoring all the databases and the MySQL Configuration file as well.

Restore all the Databases to the MariaDB Server

Now you have successfully installed MariaDB in place of MySQL that got installed while you installed Virtualmin, it time to restore all the databases and the MySQL configuration file that we backed up in the first step of this tutorial.

I have listed the commands to restore all the databases and the MySQL configuration file in a step by step manner. You can follow along as you read.

i. At first, we will restore all the databases that we backed up in a file named all.dbs and was located at /home/all.dbs.

[email protected]: mysql -u root -p < /home/all.dbs

Once you run the command it will ask for the root password. You can use the same password that you used in the MySQL Server.

ii. The final step will restore the MySQL Configuration by restoring the MySQL Configuration file. For this step we will move the MySQL Configuration file named my.cnf which we backed in the first step at location /home/my.cnf

[email protected]:~# sudo rm /etc/mysql/my.cnf
[email protected]:~# sudo cp /home/my.cnf /etc/mysql/my.cnf

Once we have restored the MySQL Configuration file our migration from MySQL to MariaDB with Virtualmin installed is complete. Now we have successfully replaced MySQL with MariaDB on Ubuntu 18.04 with Virtualmin installed.

The migration process is complete but I would recommend you to follow the last step to secure your new installed MariaDB Server. Although the step is purely optional but I would highly recommend you to follow the last step as well due to security concerns.

Optional: Securing the MariaDB Server

In this optional step, we will secure our newly installed MariaDB Server. Performing this step will provide much better security to our MariaDB Server as compared to a default install of MariaDB 10.5.

There is more that you can do to secure your MariaDB Database Server but at this point running the following command is enough and provides a decent level of protection to the freshly installed Database Server.

mysql_secure_installation

Once you execute the command it will ask you a number of questions you can answer them Y or N as I have mentioned below:

Enter current password for root (enter for none):

Enter your root password here and then press enter. After this question, a number of questions will appear. You can answer all the questions with N which will provide you a fairly secured MariaDB Server at the end.

replace mysql with mariadb

That’s it

If you have any kind of questions, doubts, or comments about Virtualmin Tutorial: Replace MySQL with MariaDB on Ubuntu 18.04, make sure you post them below. I will try to reply to them ASAP ❤️

Thanks

signature

11 thoughts on “Best Virtualmin Tutorials: Replace MySQL with MariaDB on Ubuntu 18.04”

  1. I think this is one of the so much vital info for
    me. And i’m glad reading your article. However
    want to remark on few general things, The site
    style is ideal, the articles is in point of fact excellent : D.
    Just right process, cheers

    Reply
  2. If you want to use the photo it would also be good to check with the artist beforehand in case it is subject to copyright. Best wishes. Aaren Reggis Sela

    Reply
    • The photo is a screenshot which was captured by me!! So no worries about copyright.
      A big thanks to you Aaren Reggis Sela for commenting down your thoughts. I am really glad that you find my article helpful!!

      Reply
    • A big thanks to you Gilli Shaine Caprice for commenting down your thoughts. Don’t forget to share if you find my article helpful!!

      Reply
  3. I am actually glad to read this blog posts which includes plenty of useful information, thanks for providing these data. Cathrin Enos Alicea

    Reply
    • A big thanks to you Cathrin Enos Alicea for commenting down your thoughts. Don’t forget to share if you find my article helpful!!

      Reply
  4. You made some first rate points there. I looked on the internet for the issue and found most people will go together with along with your website. Amabelle Bil Olsson

    Reply
    • A big thanks to you Amabelle Bil Olsson for commenting down your thoughts. Don’t forget to share if you find my article helpful!!

      Reply
  5. I think this is among the most significant info for me. And i am glad reading your article. But should remark on some general things, The website style is ideal, the articles is really excellent : D. Good job, cheers

    Reply

Leave a Comment