Installing MariaDB with RPM instead of yum (on CentOS7)

Thomas Hysselinckx
3 min readJul 3, 2018
Photo by Rishi Deep on Unsplash

Having troubles installing MariaDB with yum on your CentOS7 server? I feel your pain. I struggled for hours, even days, before I finally decided to focus on the target, rather than on the method. I hope I can help someone by jotting down how I managed to make it work.

If you’re like me, you’ve followed the MariaDB docs and created a MariaDB.repo file (you’ve also tried without caps) and entered sudo yum install mariadb-server, getting the no package mariadb-server available error. Then you’d of course sudo yum clean all with sudo rm -rf /var/cache/yum/and so on, but without success. You’re still getting the same darn message telling you there’s no package available.

With half of your hair already grayed out, you are thinking “Should I find a system engineer on Upwork to get the task done? Seriously? It’s just installing MariaDB on my server. Besides, I don’t like anyone having access to my server, definitely no root access.”

Lucky for us, there’s another option. Although MariaDB recommends yum, I got the job done using RPM. Assuming you managed to delete every mysql/mariadb installs on your server, here’s how:

  1. This manual has got everything you need to know: https://mariadb.com/kb/en/library/installing-mariadb-with-the-rpm-tool/
  2. You may also read on and follow the steps I took. I chose my version of the package here: https://downloads.mariadb.org/ (in my case, I chose the 10.3.8 stable version https://downloads.mariadb.org/mariadb/10.3.8/, which doesn’t download the files as expected, but takes you to a new page where you can choose your version one more time.
  3. Here I selected ‘RPM package’ on the right, because that’s what we’re looking for. Only one option remains and it’s this one: https://downloads.mariadb.org/interstitial/mariadb-10.3.8/yum//from/http%3A//mariadb.cu.be/?file=6433.
  4. Ok, choices, choices, again. Well, choose your distribution. In my case, it’s CentOS7-amd64. The hostnamectl command is what you need: it’ll print out some need-to-knows about your environment. Choose the folder /rpms and there we are.
  5. As the docs say, you need at minimum 3 packages: <name-of-the-distro>-client.rpm, <name-of-the-distro>-server.rpm and <name-of-the-distro>-shared.rpm, but while installing these I learned that I also need <name-of-the-distro>-common.rpm and <name-of-the-distro>-compat.rpm.
  6. Downloading the files locally and upload them via scp to your server:
    scp /path/to/the/files your_user@your_server:/server/path/foo
  7. Login to your server. Make sure your user can sudo (you know how to do that, don’t you?). Go to the folder where you’ve uploaded the files to (cd /server/path/foo) and use this command to install the uploaded files:
    rpm -ivh MariaDB-*(i = install, v = verbose, h = hash, see https://stackoverflow.com/a/27794125/2043134)
  8. The install process should start and finish by saying to not forget to make the necessary security arrangements (e.g. the mysql_secure_installation command).
  9. But: first things, first: sudo systemctl enable mariadb and sudo systemctl start mariadb. Enabling means making sure it’ll start on boot next time (according to this great answer).
  10. Finally, run mysql_secure_installation and follow the instructions. For production use, I advise you to answer yes to all.

After this I was able to use mysql (mariadb). Come to think about it: I was still getting an error in DirectAdmin: Error connecting to MySQL: Access denied for user: ‘da_admin@localhost’ (Using password: YES). This handy script helped me out.

I hope this post can help you sort out how to install MariaDB on CentOS7 (or any other OS) with RPM more quickly than I was able to do it. Got any questions? I’ll do my best to answer them.

--

--

Thomas Hysselinckx

Problem solver and entrepreneur, building https://cashplannr.com. Generalist, interested in many different topics. Skier, runner, weight lifter.