We hope you find this tutorial helpful. In addition to guides like this one, we provide simple cloud infrastructure for developers. Learn more →

How To Install MariaDB from Binary Tarballs on Ubuntu 13.10

Posted Jan 28, 2014 10.3k views MariaDB Ubuntu

About MariaDB

Currently, MariaDB is a drop-in replacement for MySQL. This article describes the installation of MariaDB version 5.5.34 x86_64 on an Ubuntu 13.10 VPS. Binary tarballs are used for installation instead of the software repositories available through apt-get. A potential rationale for this choice would be to have complete control over the installed version of MariaDB.


There are two 64-bit versions of MariaDB on the MariaDB download page. The difference between the two versions is that one version requires GLIBC 2.14+.

To check your installed GLIBC version:

ldd --version

Output will be something like:

ldd (Ubuntu EGLIBC 2.17-93ubuntu4) 2.17
Copyright (C) 2012 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
Written by Roland McGrath and Ulrich Drepper.

In this case, version 2.17 is installed and we can proceed with downloading "mariadb-5.5.34-linux-x8664.tar.gz" (requires GLIBC2.14+).

You have to decide where you want to put the binaries, i.e. the application itself. Some opt for /usr/local/ or /opt/. Here we choose the latter.

Let's create the directory and download the tarball:

mkdir /opt/mariadb/
cd /opt/mariadb/
wget --output-document=mariadb-5.5.34-linux-x86_64.tar.gz https://downloads.mariadb.org/f/mariadb-5.5.34/kvm-bintar-quantal-amd64/mariadb-5.5.34-linux-x86_64.tar.gz/from/http:/mariadb.mirror.triple-it.nl/

Calculate the MD5 sum to verify whether the tar is valid:

md5sum mariadb-5.5.34-linux-x86_64.tar.gz

The output should match the MD5 sum given by MariaDB on the download page: 14ca3e88eb67bced630569100173ef55.


In /opt/mariadb/, extract the tar archive:

# tar xf mariadb-5.5.34-linux-x86_64.tar.gz

Symbolic links are useful to link the used/installed version to a version specific MariaDB binary directory, for easy updating to a newer version, or to revert to a previously used version in case of failure.

To create the symlink:

ln -s /opt/mariadb/mariadb-5.5.34-linux-x86_64 /opt/mariadb/mysql

Create a new user and group for MariaDB's process to run in:

groupadd mysql
useradd -g mysql mysql

Change ownership of the binary files to the newly created user and group:

chown -R mysql:mysql /opt/mariadb/mysql/


Copy your my.cnf configuration file to /etc/my.cnf. If you do not have a configuration file already, there are some files in /opt/mariadb/mysql/support-files/ to get you started. For demonstration purposes, my-small.cnf is used:

cp /opt/mariadb/mysql/support-files/my-small.cnf /etc/my.cnf

At least set the following directives in /etc/my.cnf:


basedir specifies the location of the binary files, datadir specifies where the actual database files are stored, and user specifies that MariaDB is run under the user mysql. Typically, not setting a datadir defaults to /usr/local/mysql/data.

Just to be sure the datadir directory is there:

mkdir -p /var/lib/mysql

Initialize system tables

Like MySQL, MariaDB's system tables have to be initialized:

/opt/mariadb/mysql/scripts/mysql_install_db --user=mysql --basedir=/opt/mariadb/mysql

System service

For MariaDB to be started automatically after a system reboot, we can add a system service:

ln -s /opt/mariadb/mysql/support-files/mysql.server /etc/init.d/mysql
update-rc.d mysql defaults

To start the service:

service mysql start

If you prefer to start MariaDB manually, use:

/opt/mariadb/mysql/bin/mysqld_safe --user=mysql --ledir=/opt/mariadb/mysql/bin &

Configure MariaDB

Be sure that MariaDB is up and running.

A root account is required for further configuration, to set up a root account:

/opt/mariadb/mysql/bin/mysqladmin -u root password '<pwd>'

Where <pwd> is the password desired for the root user.

Additional security configuration:

/opt/mariadb/mysql/bin/mysql_secure_installation --basedir=/opt/mariadb/mysql

which asks a couple of questions after supplying it the previously specified root password. Provide the following configuration answers:

change root pwd: n
remove anonymous users: y
disallow root login remotely: y
remote test database and access to it: y
reload privilege tables now: y

Manual entries and global execution of binaries

When manually installing MariaDB, there are no manual entries and typing a system wide command like mysql results in a The program 'mysql' is currently not installed-like error.

Put the following entries in .bashrc or similar environment file that is loaded at system level or user level. For example, vim /root/.bashrc:


Test it

Reboot the machine to test if all works correctly:

# reboot

That MariaDB is running can be verified by:

# service mysql status

try and see if the manual works:

man mysql

try and see if MariaDB works:

mysql -u root -p

Supply the root password and you should see something similar to:

Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 3
Server version: 5.5.34-MariaDB MariaDB Server

Copyright (c) 2000, 2013, Oracle, Monty Program Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]>

Next step is to further configure the database with user accounts and import data.

Article Submitted by: Wytze Hazenberg


Creative Commons License