This tutorial shows you how to install and configure MariaDB 10 and latest version on CentOS 7. As you may probably already know, MariaDB database server is now the default on CentOS. It was MySQL before but because of Oracle (MySQL parent company) GPL licensing issues, the opensource community is gradually moving away from MySQL to MariaDB.
If you don’t know the story, here’s a brief summary. Prior to Oracle owning MySQL, it was based on the GPL (GNU General Public License) which states that you can use the software free of charge, but you cannot modify and sell it unless you release the source code. This means you can use it in your closed-source project as well.
When Oracle changed the licensing agreement from the GPL model, most in the opensource community revolted and some started a group that folk out MySQL and created MariaDB.
So basically, MariaDB database server is the same as MySQL but with a GPL licensing model. If you rip out MySQL and install MariaDB, all the services that depended MySQL will not know the deference.
Now that you know a little more of why and how MariaDB was founded, let’s get going to learn how to install it on CentOS 7.
- Installing MariaDB on CentOS 7
Now that MariaDB is the default database server for CentOS, all you have to do is run the commands below to install it. The problem is, it downloads and installs an older but stable version of MariaDB.
If you want to install the latest version of MariaDB, you must add its software repository to your machine and install. To do that, run the commands below to create a repository file.
sudo vi /etc/yum.repos.d/MariaDB.repo
Then copy and paste the lines below into the file and save it.
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.0/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
Finally, run the commands below to install MariaDB 10 on your machine.
sudo yum install MariaDB-server MariaDB-client
If you run into trouble with errors that MariaDB can’t be installed because of conflict with mariadb-libs-xxxx, run the commands below to remove it then re-run the installation commands above.
sudo yum remove mariadb-libs*
It should also remove the postfix package. Re-run the commands above to install MariaDB.
When the installation completes, run the commands below to start MariaDB server.
sudo /etc/init.d/mysql start
Next, run the commands below to secure your database server.
sudo mysql_secure_installation
Next, choose Yes for the rest of the prompts until you’re done.
- Enter current password for root (enter for none): press Enter
- Set root password? Y
- New password: Type new root password
- Re-enter new password: Confirm the password
- Remove anonymous users? Y
- Disallow root login remotely? Y
- Remove test database and access to it? Y
- Reload privilege tables now? Y
The final thing go do is replace the default cnf.ini file in the /etc/ directory with one defined for MariaDB. Go to this location:
cd /usr/share/mysql
And use one of the pre-defined cnf.ini configurations available (Huge, Medium and Small) Memory sizes.
Backup your currnet cnf.ini file.
sudo mv /etc/cnf.ini /etc/cnf.ini.bak
Then copy one of the pre-defined configuration for MariaDB.
sudo cp /usr/share/mysql/my-huge.cnf /etc/cnf.ini
Restart MaraiDB and you’re done.
Enjoy!
Frequently Asked Questions
How do I install MariaDB 10 on CentOS 7?
To install MariaDB 10 on CentOS 7, you can follow the tutorial provided in the article which includes step-by-step instructions.
What is the difference between MariaDB and MySQL?
MariaDB and MySQL are similar in functionality but differ in their licensing model, with MariaDB following the GPL licensing model.
Can I install the latest version of MariaDB on CentOS 7?
Yes, you can install the latest version of MariaDB on CentOS 7 by adding its software repository to your machine and then installing it.
Why did the open-source community transition from MySQL to MariaDB?
The transition from MySQL to MariaDB was primarily due to GPL licensing issues with Oracle, leading to the creation of MariaDB as an alternative.
Is MariaDB compatible with services that were dependent on MySQL?
Yes, MariaDB is compatible with services that were dependent on MySQL, as they are essentially the same database server with a different licensing model.
What are the steps to install MariaDB on CentOS 7?
To install MariaDB on CentOS 7, you can simply run the provided commands to download and install the database server.
How can I add the MariaDB software repository to CentOS 7?
You can add the MariaDB software repository to CentOS 7 by creating a repository file and copying the provided lines into it.
What are the advantages of using MariaDB over MySQL?
One advantage of using MariaDB over MySQL is its GPL licensing model that allows for greater flexibility in usage and distribution.