Friday, May 6, 2022

[SOLVED] Get most recent MySQL version's yum repository

Issue

I want to automate the process of installing a database on my VMs. I also want the best and newest in my database software, so I want this automation to install the latest version of MySQL every time I spin up a new VM - at time of writing, that's MySQL 8.0. Currently, to download the repository, I do

$ curl https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm

and then I install it locally with yum. But when MySQL 8.1 is released, I would be downloading the repo from https://dev.mysql.com/get/mysql81-community-release-el7-1.noarch.rpm instead.

How can I reliably and most simply retrieve a url for the yum repository for the most recent version of MySQL?


Solution

There are two problems here,

1. How do you know when mysql-8.1-community edition is released ?

2. Once you know what to do with it. I assume the problem you are trying to avoid is to go and click on a URL, download to machine, install the release RPM and then update/install mysql.

Solution below assumes mysql devlopers don't change the URLs for future releases.

Looking at the yum repo file, mysql-8.0-community corresponds to this section in /etc/yum.repos.d/mysql-community.repo:

[mysql80-community]
name=MySQL 8.0 Community Server
baseurl=http://repo.mysql.com/yum/mysql-8.0-community/el/7/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

Once you know the next version is released, appending a similar section to the repo file would let you pull the next version, e.g.,

$ cat /tmp/mysql81.repo
[mysql81-community]
name=MySQL 8.1 Community Server
baseurl=http://repo.mysql.com/yum/mysql-8.1-community/el/7/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

Append the content to yum repo file and install/update using yum.

$ cat /tmp/mysql81.repo >> /etc/yum.repos.d/mysql-community.repo
$ yum --enablerepo=* clean all
$ yum --enablerepo=*mysql* update mysql


Answered By - iamauser
Answer Checked By - Mildred Charles (WPSolving Admin)