In this article we explain how one can install and use MariaDB 10.3 on RHEL 6 / CentOS 6. MariaDB is an open source relational database which provides an SQL interface for accessing data. The latest versions of MariaDB include support for GIS and JSON. MariaDB is a fork of MySQL database, with its active development under open source community.
MariaDB latest packages are not available in Red Hat or CentOS provided RPM repositories. We’ll have to add MariaDB provided repository then install the packages from there. I believe you can also use Software Collections repository, but I didn’t try using it.
Add MariaDB 10.3 repository to RHEL 6 / CentOS 6
Let’s add MariaDB 10.3 YUM repository to our RHEL 6 / CentOS 6 system:
sudo tee /etc/yum.repos.d/mariadb.repo<<EOF [mariadb] name = MariaDB baseurl = http://yum.mariadb.org/10.3/centos6-amd64 gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB gpgcheck=1 EOF
sudo tee /etc/yum.repos.d/mariadb.repo<<EOF [mariadb] name = MariaDB baseurl = http://yum.mariadb.org/10.3/rhel6-amd64 gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB gpgcheck=1 EOF
Once the repository is added update package cache index to confirm it is working.
sudo yum clean all sudo yum makecache
List available repositories:
$ sudo yum repolist
RHEL 6 command output:
Loaded plugins: product-id, refresh-packagekit, search-disabled-repos, security, subscription-manager repo id repo name status mariadb MariaDB 48 rhel-6-server-extras-rpms Red Hat Enterprise Linux 6 Server - Extras (RPMs) 104 rhel-6-server-optional-rpms Red Hat Enterprise Linux 6 Server - Optional (RPMs) 12,262 rhel-6-server-rpms Red Hat Enterprise Linux 6 Server (RPMs) 21,210 repolist: 33,624
Accept installation of MariaDB 10.3 on RHEL 6 / CentOS 6 system:
Dependencies Resolved ================================================================================================================================================================== Package Arch Version Repository Size ================================================================================================================================================================== Installing: MariaDB-client x86_64 10.3.27-1.el6 mariadb 59 M MariaDB-compat x86_64 10.3.27-1.el6 mariadb 4.0 M replacing mysql-libs.x86_64 5.1.73-8.el6_8 MariaDB-server x86_64 10.3.27-1.el6 mariadb 136 M Installing for dependencies: MariaDB-common x86_64 10.3.27-1.el6 mariadb 176 k boost-program-options x86_64 1.41.0-28.el6 rhel-6-server-rpms 108 k galera x86_64 25.3.29-1.rhel6.el6 mariadb 9.2 M perl-DBI x86_64 1.609-4.el6 rhel-6-server-rpms 707 k Transaction Summary ================================================================================================================================================================== Install 7 Package(s) Total download size: 209 M Is this ok [y/N]: y
Agree to importation of repository GPG key:
warning: rpmts_HdrFromFdno: Header V4 DSA/SHA1 Signature, key ID 1bb943db: NOKEY Retrieving key from https://yum.mariadb.org/RPM-GPG-KEY-MariaDB Importing GPG key 0x1BB943DB: Userid: "MariaDB Package Signing Key <[email protected]>" From : https://yum.mariadb.org/RPM-GPG-KEY-MariaDB Is this ok [y/N]: y
Install MariaDB 10.3 on RHEL 6 / CentOS 6
With the repository added and confirmed to be working we can begin installation of MariaDB 10.3 on CentOS 6 / RHEL 6 system.
sudo yum install MariaDB-server MariaDB-client
Start the database service.
$ sudo /etc/rc.d/init.d/mysql start Starting MariaDB.210129 20:57:51 mysqld_safe Logging to '/var/lib/mysql/localhost.localdomain.err'. 210129 20:57:51 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql SUCCESS!
Enable the database service to be started on system boot.
sudo chkconfig mysql on
The service should be running:
$ sudo service mysql status SUCCESS! MariaDB running (3175)
Secure MariaDB Database Server
The final step is to secure our database server installation by setting the root user password, removing test database and anonymous users, and disabling remote root user login.
$ sudo mysql_secure_installation 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! 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!
Try authenticating to MariDB shell using the set password for the root user.
$ mysql -u root -p Enter password: Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 17 Server version: 10.3.27-MariaDB MariaDB Server Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
Confirm the version of MariaDB database server we’re running.
MariaDB [(none)]> SELECT VERSION(); +-----------------+ | VERSION() | +-----------------+ | 10.3.27-MariaDB | +-----------------+ 1 row in set (0.000 sec)
Exit MariaDB shell:
MariaDB [(none)]> quit Bye
We have successfully installed MariaDB 10.3 on CentOS 6 / RHEL 6, started the service and secure the database server.