Install MariaDB 5.5 Database in RHEL/CentOS/Fedora and Debian/Ubuntu

Posted by

MariaDB is a binary drop-in replacement for MySQL, developed by original authors of MySQL Project and fully compatible with MySQL having more features and better performance enhancement. Till we wrote this post, MariaDB 10.0 Series is the development version (Alpha) and MariaDB 5.5 is the current stable (GA) release.

Install MariaDB in Linux

Why should I use MariaDB?

As we all know MySQL is widely used and the most popular RDBMS and first choice of developers. In 2008MySQL was acquired by Sun Microsystem, which was subsequently bought by Oracle and which is no longer open source.

Well, MariaDB is sponsored by Monty Program AB & MariaDB Foundation and is independently developed by the core developer of MySQL and other community members and truly open source. The man who created MySQL database by Michael “Monty” WideniusDavid Axmark, and Allan Larsso the founder of MySQL and Monty Program AB is now behind MariaDB. They would oversee the development of MariaDB foundation.

Who are using MariaDB?

There are number of distributions & large websites have switched to MariaDB, some of them are:

  1. Mozilla Corporation
  2. Wikipedia
  3. OpenSuse
  4. Fedora
  5. OLX
  6. Nimbuzz
  7. SlashGear
  8. ArchLinux
  9. Redhat Enterprise Linux (from RHEL7)
  10. Slackware
  11. Mageia
  12. Slackware
  13. TurboLinux
  14. The Chakra Project
  15. Gentoo
  16. GNU/Linux KDu

Installing MariaDB Database in RHEL/CentOS 6/5 and Fedora 18/17

We highly recommended to use custom MariaDB YUM (Package Manager) repository to install. Create a repo file under /etc/yum.repos.d/MariaDB.repo, Copy and paste following entries under it.

Adding the MariaDB YUM Repository

Currently, MariaDB repositories available for RHEL 6RHEL5CentOS 6CentOS 5, and Fedora 20,19,18,17. Please choose and add correct repository to your OS version.

On RHEL 6 32-bit
# MariaDB 5.5 RedHat repository list - created 2013-08-11 14:29 UTC
# http://mariadb.org/mariadb/repositories/

name = MariaDB baseurl = http://yum.mariadb.org/5.5/rhel6-x86 gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB gpgcheck=1

On RHEL 6 64-bit
# MariaDB 5.5 RedHat repository list - created 2013-08-11 14:30 UTC
# http://mariadb.org/mariadb/repositories/

name = MariaDB baseurl = http://yum.mariadb.org/5.5/rhel6-amd64 gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB gpgcheck=1

On RHEL 5 32-bit
# MariaDB 5.5 RedHat repository list - created 2013-08-11 14:31 UTC
# http://mariadb.org/mariadb/repositories/

name = MariaDB baseurl = http://yum.mariadb.org/5.5/rhel5-x86 gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB gpgcheck=1

On RHEL 5 64-bit
# MariaDB 5.5 RedHat repository list - created 2013-08-11 14:31 UTC
# http://mariadb.org/mariadb/repositories/

name = MariaDB baseurl = http://yum.mariadb.org/5.5/rhel5-amd64 gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB gpgcheck=1

On CentOS 6 32-bit
# MariaDB 5.5 CentOS repository list - created 2013-08-11 14:21 UTC
# http://mariadb.org/mariadb/repositories/

name = MariaDB baseurl = http://yum.mariadb.org/5.5/centos6-x86 gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB gpgcheck=1

On CentOS 6 64-bit
# MariaDB 5.5 CentOS repository list - created 2013-08-11 14:22 UTC
# http://mariadb.org/mariadb/repositories/

name = MariaDB baseurl = http://yum.mariadb.org/5.5/centos6-amd64 gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB gpgcheck=1

On CentOS 5 32-bit
# MariaDB 5.5 CentOS repository list - created 2013-08-11 14:23 UTC
# http://mariadb.org/mariadb/repositories/

name = MariaDB baseurl = http://yum.mariadb.org/5.5/centos5-x86 gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB gpgcheck=1

On CentOS 5 64-bit
# MariaDB 5.5 CentOS repository list - created 2013-08-11 14:23 UTC
# http://mariadb.org/mariadb/repositories/

name = MariaDB baseurl = http://yum.mariadb.org/5.5/centos5-amd64 gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB gpgcheck=1

On Fedora 20 32-Bit
# MariaDB 5.5 Fedora repository list - created 2014-03-19 06:34 UTC
# http://mariadb.org/mariadb/repositories/

name = MariaDB baseurl = http://yum.mariadb.org/5.5/fedora20-x86 gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB gpgcheck=1

On Fedora 20 64-Bit
# MariaDB 5.5 Fedora repository list - created 2014-03-19 06:35 UTC
# http://mariadb.org/mariadb/repositories/

name = MariaDB baseurl = http://yum.mariadb.org/5.5/fedora20-amd64 gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB gpgcheck=1

On Fedora 19 32-Bit
# MariaDB 5.5 Fedora repository list - created 2014-03-19 06:31 UTC
# http://mariadb.org/mariadb/repositories/

name = MariaDB baseurl = http://yum.mariadb.org/5.5/fedora19-x86 gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB gpgcheck=1

On Fedora 19 64-Bit
# MariaDB 5.5 Fedora repository list - created 2014-03-19 06:34 UTC
# http://mariadb.org/mariadb/repositories/

name = MariaDB baseurl = http://yum.mariadb.org/5.5/fedora19-amd64 gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB gpgcheck=1

On Fedora 18 32-Bit
# MariaDB 5.5 Fedora repository list - created 2013-08-11 14:32 UTC
# http://mariadb.org/mariadb/repositories/

name = MariaDB baseurl = http://yum.mariadb.org/5.5/fedora18-x86 gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB gpgcheck=1

On Fedora 18 64-Bit
# MariaDB 5.5 Fedora repository list - created 2013-08-11 14:33 UTC
# http://mariadb.org/mariadb/repositories/

name = MariaDB baseurl = http://yum.mariadb.org/5.5/fedora18-amd64 gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB gpgcheck=1

On Fedora 17 32-Bit
# MariaDB 5.5 Fedora repository list - created 2013-08-11 14:33 UTC
# http://mariadb.org/mariadb/repositories/

name = MariaDB baseurl = http://yum.mariadb.org/5.5/fedora17-x86 gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB gpgcheck=1

On Fedora 17 64-Bit
# MariaDB 5.5 Fedora repository list - created 2013-08-11 14:33 UTC
# http://mariadb.org/mariadb/repositories/

name = MariaDB baseurl = http://yum.mariadb.org/5.5/fedora17-amd64 gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB gpgcheck=1

Once you’ve placed MariaDB.repo file under /etc/yum.repos.d/. Let’s install with following YUM command.

# On RHEL/CentOS 6/5 and Fedora 19,18,17 #
[root@linuxtechexpert]# yum -y install MariaDB MariaDB-server

# On Fedora 20 #
[root@linuxtechexpert]# yum -y install mariadb mariadb-server

If, MariaDB GPG Signing key not installed, YUM will automatically install it after downloading all the packages.

Starting MariaDB

After the installation completes, start MariaDB with following command.

# On RHEL/CentOS 6/5 and Fedora 19,18,17 #
[root@linuxtechexpert]# /etc/init.d/mysql start

# On Fedora 20 #
[root@linuxtechexpert]# systemctl start mariadb.service 
[root@linuxtechexpert]# systemctl enable mariadb.service
Login MariaDB

Type the ‘mysql‘ command in the terminal. By default password for root is blank.

[root@linuxtechexpert]# mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 1
Server version: 5.5.32-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)]>
View Existing Databases

Run the following command to view default databases that comes with installation.

MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
+--------------------+
4 rows in set (0.00 sec)

Type quit from command prompt to exit from shell.

MariaDB [(none)]> quit
Bye
Post Installation of MariaDB

Post installation, you should read and below each steps carefully which will set root passwordremove anonymous usersdisallow remote root login, and remove the test database and access to secure MariaDB.

[root@linuxtechexpert yum.repos.d]#  mysql_secure_installation
/usr/bin/mysql_secure_installation: line 379: find_mysql_client: command not found

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none):

OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n] Y

New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
 ... Success!

Remove anonymous users? [Y/n] y
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] y
 ... Success!

By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!
Restart MariaDB and Connect

Once post installation script completes, you need to Restart MariaDB database to take new changes.

# On RHEL/CentOS 6/5 and Fedora 19,18,17 #
[root@linuxtechexpert]# /etc/init.d/mysql restart

# On Fedora 20 #
[root@linuxtechexpert]# systemctl restart mariadb.service 

Set MariaDB to start on boot

[root@linuxtechexpert yum.repos.d]# chkconfig mysql on

Let’s try to connect with newly set root credential and we should see something like.

[root@linuxtechexpert yum.repos.d]# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 1
Server version: 5.5.32-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)]>

Installing MariaDB Database in Debian 7/6 and Ubuntu 13.04/12/10/12.04

We highly recommended to use custom repository to install. Run the following commands to add MariaDB to your system. Please note signing key will remains same in Debian and Ubuntu while importing the same.

On Debian 7 Wheezy and Debian 6 Squeeze
narad@narad-linuxtechexpert:~$ sudo apt-get install python-software-properties
narad@narad-linuxtechexpertt:~$ sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 0xcbcb082a1bb943db

Copy and paste the following entries into a file /etc/apt/sources.list at the bottom.

On Debian 7 Wheezy
# MariaDB 5.5 repository list - created 2013-08-11 15:03 UTC
# http://mariadb.org/mariadb/repositories/
deb http://mirrors.scie.in/mariadb/repo/5.5/debian wheezy main
deb-src http://mirrors.scie.in/mariadb/repo/5.5/debian wheezy main
On Debian 6 Squeeze
# MariaDB 5.5 repository list - created 2013-08-11 15:17 UTC
# http://mariadb.org/mariadb/repositories/
deb http://mirrors.scie.in/mariadb/repo/5.5/debian squeeze main
deb-src http://mirrors.scie.in/mariadb/repo/5.5/debian squeeze main
On Ubuntu 13.10 Saucy
# MariaDB 5.5 repository list - created 2014-03-19 06:47 UTC
# http://mariadb.org/mariadb/repositories/
deb http://mirrors.scie.in/mariadb/repo/5.5/ubuntu saucy main
deb-src http://mirrors.scie.in/mariadb/repo/5.5/ubuntu saucy main
On Ubuntu 13.04 Raring
# MariaDB 5.5 repository list - created 2013-08-11 15:18 UTC
# http://mariadb.org/mariadb/repositories/
deb http://mirrors.scie.in/mariadb/repo/5.5/ubuntu raring main
deb-src http://mirrors.scie.in/mariadb/repo/5.5/ubuntu raring main
On Ubuntu 12.04 Quantal
# MariaDB 5.5 repository list - created 2013-08-11 15:24 UTC
# http://mariadb.org/mariadb/repositories/
deb http://mirrors.scie.in/mariadb/repo/5.5/ubuntu quantal main
deb-src http://mirrors.scie.in/mariadb/repo/5.5/ubuntu quantal main
On Ubuntu 12.04 Precise
# MariaDB 5.5 repository list - created 2013-08-11 15:24 UTC
# http://mariadb.org/mariadb/repositories/
deb http://mirrors.scie.in/mariadb/repo/5.5/ubuntu precise main
deb-src http://mirrors.scie.in/mariadb/repo/5.5/ubuntu precise main

Once you’ve correctly imported key and added repository properly, you can install MariaDB with apt-get command as shown. During installation you may ask to setup root password for database.

narad@narad-linuxtechexpert:~$ sudo apt-get update
narad@narad-linuxtechexpert:~$ sudo apt-get install mariadb-server
Set MariaDB root Password
Enter MariaDB root Password
Login into MariaDB

Login MariaDB with root credential which was set earlier.

narad@narad-linuxtechexpert:~$ sudo mysql -u root -p
[sudo] password for narad: 
Enter password:
MariaDB prompt
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 42
Server version: 10.0.3-MariaDB-1~raring-log mariadb.org binary distribution

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)]>
View Existing Databases
MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
+--------------------+
3 rows in set (0.00 sec)

Note: Type quit from command prompt to exit from database.

Reference Links

  1. MariaDB Vs MySQL – Features
  2. MariaDB Documentation
  3. MariaDB homepage

5 comments

  1. I was extremely pleased to discover this page. I want to to thank you for ones time due to this wonderful read!! I definitely appreciated every part of it and I have you bookmarked to look at new information on your web site.

Leave a Reply

Your email address will not be published. Required fields are marked *