Installing MariaDB on Fedora, Red Hat, and CentOS
The procedure to install MariaDB on Fedora, Red Hat, and CentOS makes use of the Yellowdog Updater, Modified (YUM) package manager. There are two steps: first, create a repo file for MariaDB and second, install MariaDB.
To generate the required text for the repo file, we will visit the MariaDB repository configuration tool from:
https://downloads.mariadb.org/mariadb/repositories/
Tip
This tool is used for APT-based Linux distributions, such as Debian, Ubuntu, and Mint; Yum-based Linux distributions, such as Fedora, CentOS, and Red Hat; and other distributions that have support for MariaDB built-in, such as Mageia, Arch Linux, Suse, openSUSE, and others.
To generate the text, we simply click on the distribution we are using, the distribution release we are using, and the version of MariaDB we want to install. After doing so, the contents of the appropriate repo file will be displayed.
For example, the text generated for MariaDB 10.1 on the 64-bit version of CentOS 7 is as follows:
# MariaDB 10.1 CentOS repository list # http://mariadb.org/mariadb/repositories/ [mariadb] name = MariaDB baseurl = http://yum.mariadb.org/10.1/centos7-amd64 gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB gpgcheck=1
The gpgkey
line tells YUM where the GPG signing key is located. The gpgcheck=1
line directs YUM to always use the signing key to verify the MariaDB packages.
The first time we install MariaDB, our system will not have the key, so YUM will have to download and install it. Since YUM has never used the key before, it will ask for confirmation whether it is OK to import the key. See the MariaDB package security section for more information on the MariaDB GPG signing key.
We copy and paste the generated text into a file using our favorite text editor. Naming the file descriptively, such as MariaDB.repo
, is recommended. Once the file is created, we then move it to the /etc/yum.repos.d/
folder using a command similar to the following one:
sudo mv -vi MariaDB.repo /etc/yum.repos.d/
Once the file is in place, we are ready to install MariaDB. This is as simple as the following:
sudo yum install MariaDB-server MariaDB-client
The capitalization of the package names is important because if we type mariadb-server
instead of MariaDB-server
, we will either get a package cannot be found error or, if we are using a distribution that includes MariaDB, we will get the distribution version of MariaDB instead of the version from the MariaDB project.
YUM will gather in all of the dependencies for MariaDB and present us with a list of everything that needs to be installed to install MariaDB. The following screenshot shows this:
After answering y
, the installation will get going and we will be prompted to accept the GPG signing key. We will verify the fingerprint with y
. YUM will then continue downloading and installing MariaDB and will end with a Complete!
message.
As a final step of the installation, we start MariaDB with the following command:
sudo /etc/init.d/mysql start
If everything has gone well, we will see output similar to the following:
[dbart@centos70-x86-64 ~]$ sudo /etc/init.d/mysql start Starting MySQL.. SUCCESS!
MariaDB is now installed and running.
Jump ahead to the MariaDB package security section if you're interested in the MariaDB GPG signing key, or skip to the After the installation section if you want to start using MariaDB right away.