Applications

How to Convert from MySQL to MariaDB on Ubuntu 17.04

Posted By !robot

This post is intended to help students and new users switch from MySQL database server to MariaDB database server in Ubuntu 17.04. This should probably also work with other versions of Ubuntu.

As you may already know, MariaDB is rapidly becoming the default database server on Linux systems, including Ubuntu. Over the past years, MySQL was the undisputed database king for all Linux distributions.

After Oracle Corporation purchased the previous parent company of MySQL and made some controversial licensing changes, the opensource community has gradually started drifting away from MySQL towards MariaDB.

MariaDB is a drop-in replacement for MySQL. This means, it operates and functions like MySQL. If you remove MySQL and install MariaDB, applications that depended on MySQL won’t know the difference after installing MariaDB.

For the tutorial to be applied, you must already have MySQL installed on Ubuntu

Step 1: Removing MySQL Database Server

To get rid of MySQL from Ubuntu, run the commands below.

sudo systemctl stop mysql.service
sudo apt-get remove mysql-server mysql-common libmysqlclient18

After running the above commands, continue below to install MariaDB database server.

Step 2: Installing MariaDB Database Server

Now that MySQL is removed from Ubuntu, run the commands below to install MariaDB.

sudo apt-get install mariadb-server mariadb-client libmariadbclient18

The commands above should install the stable version of MariaDB database server from Ubuntu repositories.

During the installation, you may get the message below that the old data directory location will be saved at new location.. Accept and continue.

┌────────────────────┤ Configuring mariadb-server-10.1 ├──────
│ The old data directory will be saved at new location
│ A file named /var/lib/mysql/debian-*.flag exists on this system. The
│ number indicates a database binary format version that cannot
│ automatically be upgraded (or downgraded).
│ Therefore the previous data directory will be renamed to
│ /var/lib/mysql-* and a new data directory will be initialized at
│ /var/lib/mysql.
│ Please manually export/import your data (e.g. with mysqldump) if needed.
│                                  <Ok>
│
└────────────────────────────────────────────────────────

However, if you need to install the latest versions or MariaDB, run the commands below to add MariaDB repository key to Ubuntu.

sudo apt-get install software-properties-common
sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8

Then, run the commands below to add MariaDB version 10.1 branch or repository to Ubuntu.

sudo sh -c "echo 'deb [arch=amd64,i386] https://mirrors.evowise.com/mariadb/repo/10.1/ubuntu '$(lsb_release -cs)' nginx' > /etc/apt/sources.list.d/MariaDB-10.1.list"

Finally, run the commands below to install MariaDB from the 10.1 branch.

sudo apt-get update
sudo apt-get install mariadb-server mariadb-client

If you want to install the latest unreleased 10.2 version, add the repository below.

sudo sh -c "echo 'deb [arch=amd64,i386] https://mirrors.evowise.com/mariadb/repo/10.2/ubuntu '$(lsb_release -cs)' nginx' > /etc/apt/sources.list.d/MariaDB-10.2.list"

Then run the commands below to update to the latest 10.2 version.

sudo apt-get update
sudo apt-get install mariadb-server mariadb-client

That’s it!

Summary:

Again, this post shows you how to convert from MySQL to MariaDB database server. Since almost all Linux distributions are now switching from MySQL to MariaDB, it’s probably the best thing to switch as well for better system support.

If you’re currently running MySQL on your server, follow the steps above to switch to MariaDB.

You may also like the post below:

Installing PHP 7.0 or 7.1 on Ubuntu 17.04


This post wasn't created by a robot! I'm real and I spend some of my spare time searching for ways to help students and new users get to know and understand Linux, Ubuntu, Windows, and Open Source software. Every tutorial I write I try to write it as simple as possible so someone who's new to technology can easily follow. This site is dedicated to IT students and new users who want to learn about Linux, Ubuntu, Windows, Open Source and more. Thanks!

View Comments
There are currently no comments.