MariaDB 10.3 stable version has been released on Oct 09, 2017. It is an enhanced, drop-in replacement for MySQL. MariaDB can be an better choice for choice for database professionals looking for a robust, scalable, and reliable SQL server. MariaDB has a number of updated features over MySQL. Use below links to read features comparison between MariaDB and MySQL. This article will help you to install MariaDB 10.3 in CentOS, RHEL 7/6 and Fedora Fedora 28/27/26/25/24 systems using yum.
Step 1: Add MariaDB Yum Repositories
First add MariaDB yum repository in our system. Create a new repo file /etc/yum.repos.d/mariadb.repo in your system and add below code as per your operating system and architecture.
For CentOS/RHEL – 7
[mariadb] name = MariaDB baseurl = http://yum.mariadb.org/10.3/rhel7-amd64 gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB gpgcheck=1
For CentOS/RHEL – 6
[mariadb] name = MariaDB baseurl = http://yum.mariadb.org/10.3/rhel6-amd64 gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB gpgcheck=1
For Fedora – 28/27/26/25/24
Please change version (red highlighted) in below setting as per version of Fedora you used. Click here To view all available repositories.
[mariadb] name = MariaDB baseurl = http://yum.mariadb.org/10.3/fedora
26-amd64 gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB gpgcheck=1
Step 2 – Install MariaDB Server
Let’s use the following command to install MariaDB 10.2 in your system. This will also install other dependencies automatically.
sudo yum install MariaDB-server MariaDB-client
After installing MariaDB in your system start it’s service using the following command.
## CentOS/Redhat 7 & Fedora sudo systemctl start mysql.service ## CentOS/Redhat 6 sudo service mysql start
Step 3 – Secure MariaDB Install
You also need to secure your MariaDB installation using passwords and do some other changes. To do this run secure installation script from command line.
The secure installation script will ask for user input as some points, follow the installation as per below output showing, All user inputs are highlighted with red color.
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] yNew password: Re-enter new password: Password updated successfully! Reloading privilege tables.. ... Success! By default, a MariaDB installation has an anonymous user, allowing anyone to log into MariaDB without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment. 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!
Step 4 – Working with MariaDB
After installing and completing the configuration, connect to MariaDB server using the following command.
sudo mysql -u root -p Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 16 Server version: 10.3.2-MariaDB MariaDB Server Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]>
Also try to create a new database, user and assign privileges to a database.
## CREATE DATABASE
MariaDB [(none)]> CREATE DATABASE mydb;
## CREATE USER ACCOUNT
MariaDB [(none)]> CREATE USER 'dbuser'@'192.168.10.101' IDENTIFIED BY 'secret';
## GRANT PERMISSIONS ON DATABASE
MariaDB [(none)]> GRANT ALL ON mydb.* TO 'dbuser'@'192.168.10.101';
## RELOAD PRIVILEGES
MariaDB [(none)]> FLUSH PRIVILEGES;
You may also required install phpMyAdmin to manage MariaDB using web interface, which provides easy way to work.