Install MariaDB 5.5 Database in RHEL/CentOS/Fedora and Debian/Ubuntu
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.
Why should I use MariaDB?
As we all know MySQL is widely used and the most popular RDBMS and first choice of developers. In 2008, MySQL 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” Widenius, David 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:
- Mozilla Corporation
- Wikipedia
- OpenSuse
- Fedora
- OLX
- Nimbuzz
- SlashGear
- ArchLinux
- Redhat Enterprise Linux (from RHEL7)
- Slackware
- Mageia
- Slackware
- TurboLinux
- The Chakra Project
- Gentoo
- 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 6, RHEL5, CentOS 6, CentOS 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/ [mariadb] 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/ [mariadb] 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/ [mariadb] 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/ [mariadb] 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/ [mariadb] 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/ [mariadb] 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/ [mariadb] 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/ [mariadb] 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/ [mariadb] 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/ [mariadb] 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/ [mariadb] 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/ [mariadb] 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/ [mariadb] 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/ [mariadb] 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/ [mariadb] 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/ [mariadb] 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 # [[email protected]]# yum -y install MariaDB MariaDB-server # On Fedora 20 # [[email protected]]# 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 # [[email protected]]# /etc/init.d/mysql start # On Fedora 20 # [[email protected]]# systemctl start mariadb.service [[email protected]]# systemctl enable mariadb.service
Login MariaDB
Type the ‘mysql‘ command in the terminal. By default password for root is blank.
[[email protected]]# 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 password, remove anonymous users, disallow remote root login, and remove the test database and access to secure MariaDB.
[[email protected] 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 # [[email protected]]# /etc/init.d/mysql restart # On Fedora 20 # [[email protected]]# systemctl restart mariadb.service
Set MariaDB to start on boot
[[email protected] yum.repos.d]# chkconfig mysql on
Let’s try to connect with newly set root credential and we should see something like.
[[email protected] 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
[email protected]:~$ sudo apt-get install python-software-properties [email protected]:~$ 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.
[email protected]:~$ sudo apt-get update [email protected]:~$ sudo apt-get install mariadb-server
Login into MariaDB
Login MariaDB with root credential which was set earlier.
[email protected]:~$ 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.
The mirror http://mirrors.scie.in/mariadb/repo/5.5 was mentioned for installing the MariaDB on debian and ubuntu is no more possible. Is there any alternative mirrors?
@Sajjad,
Sorry for trouble, we will check and update the article to most recent MariaDB version.
When is this update going to be done?????
@Kevin,
Hopefully by this weekend this is going to update to latest MariaDB, sorry for trouble..
Please do the followings:-
1. Stop MariaDB
2. Copy the existing data directory i.e. /var/lib/mysql (default location) to new location
3. Edit the MariaDB configuration file.
4. Search entry for datadir or create the new one as below.
datadir = /newpath
5. Restart mariadb service.
What abt The latest version can that be installed?
Yes you can, but I need to update this article to support latest stable version installation.
My installation is centos 6.5 and MariaDB 10.07
I use mariadb over a year on my notebook (fedora 19, and currently mariadb 5.5). On the notebook I changes the data directory to /home/db/mariadb by changing in /etc/my.cnf datadir=/var/lib/mysql to datadir=/home/db/mariadb. After restart of mysqld it works fine and all my data resides in that directory.
In the instant case /etc/my.cnf does not contain any data. Likewise the sample cnf file do not have an entry for datadir. Once the parameter datadir is entered the server starts but complains, in my case, on write error due to inability to access /var/lib/mysql/[my server name].pid.
Can you please suggest how to change datadir on Centos 6.5 with MariaDB 10.07. If I live the deafault of /var/lib/mysql, every thing works fine.
Narad, any thoughts on trying to run this on s390x architecture ?
PS: you dont need a real IBM mainframe to port, you can use Hecules ie: http://fedoraproject.org/wiki/Architectures/s390x
i got this error after replacing default installed MariaDB to MYSQL in my Fedora 19
ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’ (2)
I tried installing MariaDB again but i still got the error (after removing mysql server)
Check your mysql daemon is running if not start with below command.
Start the mysqld daemon.
# systemctl start mysqld
To enable mysql daemon to start at boot
# systemctl enable mysqld.service