How to Replace MySQL with MariaDB in Ubuntu Server

Last night I thought it would be a good idea to try MariaDB on an Ubuntu server. What a mistake! The MariaDB installation screwed up. Took 4 hours to fix my server but I did eventually get MariaDB installed in Ubuntu, yay!

My home server used Apache2, MySQL and PHP, all managed with Webmin and the Linux terminal. My OS is Kubuntu.

There is a known bug with the Ubuntu MariaDB installation process: MariaDB replaces libmysqlclient18 with libmariadbclient18.

The two clients cannot be co-installed and that is the problem — libmariadbclient18 replaces libmysqlclient18 and other packages depend on.. wait for it.. libmysqlclient18 so libmysqlclient18 can’t be removed without breaking other packages (or removing them). All is well once libmariadbclient18 is installed but the OS won’t automatically remove one before it installs the other.

Would have been good to know about the MariaDB installation bug before I jumped into my 4 hour Linux adventure. Guess that’s what I get for not reading the instructions on the box.

Your MariaDB install will be quicker than mine was

You won’t need to worry about the installation problems because I fought the battle, destroyed the LAMP server demons and made my way to castle MariaDB during my Tuesday night adventure.

So, here is what you are here for, how to replace MySQL with MariaDB on an Ubuntu server.

How to install MariaDB into Ubuntu

MariaDB is a drop-in replacement for MySQL. This means that your existing MySQL databases will work with MariaDB. The MariaDB Server  installer asked me whether I wanted to convert my existing MySQL databases into MariaDB databases. I agreed and — once the installation bug described later in this guide was quashed — the converted databases worked well.

Always backup existing databases just in case anything goes wrong. Do a database dump. Instructions here.

Alternatively, if you know what you are doing, you can back up the databases by copying them from /var/lib/mysql/ with

sudo cp -r /var/lib/mysql ~/

You can only view the content of /var/lib/mysql as a root user.

Add the MariaDB repository

Visit the MariaDB repository builder page and use the options to build the correct MariaDB repository for your version of Ubuntu.

For Ubuntu 15.04 (Vivid), MariaDB 10.0 (current latest stable version) and UK code mirror, your repo code and installation instructions will look like this:

sudo apt-get install software-properties-common
sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xcbcb082a1bb943db
sudo add-apt-repository 'deb http://mirrors.coreix.net/mariadb/repo/10.0/ubuntu vivid main'

Install MariaDB with

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

During the installation process you might see an error message like this:

The following packages have unmet dependencies.
 libmariadbclient18 : Depends: libmysqlclient18 (= 10.0.14+maria-1~trusty) but 5.5.40-0ubuntu1 is to be installed
 libmysqlclient18 : Depends: mysql-common (>= 5.5.40-0ubuntu1) but it is not going to be installed
 mariadb-common : Depends: mysql-common but it is not going to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).

Or an error message like this:

dpkg: error processing archive /var/cache/apt/archives/libmysqlclient18_10.0.14+maria-1~trusty_amd64.deb (--unpack):
 libmysqlclient18:amd64 10.0.14+maria-1~trusty (Multi-Arch: no) is not co-installable with libmysqlclient18 which has multiple installed instances
Errors were encountered while processing:
 /var/cache/apt/archives/libmysqlclient18_10.0.14+maria-1~trusty_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

If either of those error messages show, open the DPKG status file with (for KDE):

kdesudo kate /var/lib/dpkg/status

Or, if you’re using Ubuntu, use this instead

gksudo gedit /var/lib/dpkg/status

When the status file opens, find this chunk of text. The important bit being ‘Package: libmysqlclient18:

Package: libmysqlclient18
Status: deinstall ok config-files
Priority: optional
Section: libs
Installed-Size: 3392
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Architecture: i386
Multi-Arch: same
Source: mysql-5.5
Version: 5.5.40-0ubuntu1
Config-Version: 5.5.40-0ubuntu1
Depends: mysql-common (>= 5.5.40-0ubuntu1), libc6 (>= 2.4), libgcc1 (>= 1:4.1.1), zlib1g (>= 1:1.1.4)
Pre-Depends: multiarch-support
Description: MySQL database client library
 MySQL is a fast, stable and true multi-user, multi-threaded SQL database
 server. SQL (Structured Query Language) is the most popular database query
 language in the world. The main goals of MySQL are speed, robustness and
 ease of use.
 .
 This package includes the client library.
Homepage: http://dev.mysql.com/
Original-Maintainer: Debian MySQL Maintainers <pkg-mysql-maint@lists.alioth.debian.org>

Remove that chunk of text and save the file.

Now run the installer again with:

sudo apt-get install mariadb-server

The MariaDB installation should now complete properly.

If you ever need to put that chunk of text back into the DPKG status file, just remember it goes in after ‘Package: libmariadbclient18’.

Sharing is caring!

Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

7 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
7
0
Would love your thoughts, please comment.x
()
x