Build MySQL 8 from the source rpm in OL8

After having explained how to build MySQL 8 (MySQL 8.0 and MySQL 8.1) on OL9 and OL7, this episode of the series will cover how to build MySQL 8 on Oracle Linux 8 (OL8) and compatible (EL8, CentOS 8, …).

My build machine is a VM.Standard.E4.Flex instance on OCI having 8 OCPUs and 128GB of ram with Oracle Linux 8.8. The machine has also a block volume of 50GB attached and mounted in /home/opc/rpmbuild:

Getting the source RPM

To get the source RPM, you need first to install the MySQL Community’s repo:

$ sudo dnf install -y https://dev.mysql.com/get/mysql80-community-release-el8-7.noarch.rpm

But comparing to OL7 and OL9, this is maybe the most complicate process if you are not aware of how to proceed.

To be able to use the MySQL Community Repo, we need first to remove the one provided by the system (see this article):

$ sudo dnf module disable mysql -y

And now we can download the src rpm for the version we want to recompile.

For MySQL 8.0:

$ dnf download --source mysql-community-server

And for the latest MySQL Innovation Release (8.1):

$ dnf download --source mysql-community-server --enablerepo=mysql-innovation-community

On my system, both files are present:

$ ls -lh *src.rpm
-rw-rw-r--. 1 opc opc 514M Aug 19 11:12 mysql-community-8.0.34-1.el8.src.rpm
-rw-rw-r--. 1 opc opc 515M Aug 19 11:11 mysql-community-8.1.0-1.el8.src.rpm

Dependencies

To build RPMs, you need at least the following package:

$ sudo dnf install -y rpm-build

Of course MySQL also need several packages including libraries and compiler required to compile it. To know which one we need, we can already try to rebuild the rpm:

$ rpmbuild  --rebuild mysql-community-8.1.0-1.el8.src.rpm 
[...]
error: Failed build dependencies:
	cmake >= 3.6.1 is needed by mysql-community-8.1.0-1.el8.x86_64
	cyrus-sasl-devel is needed by mysql-community-8.1.0-1.el8.x86_64
	gcc-toolset-12-annobin-annocheck is needed by mysql-community-8.1.0-1.el8.x86_64
	gcc-toolset-12-annobin-plugin-gcc is needed by mysql-community-8.1.0-1.el8.x86_64
	libaio-devel is needed by mysql-community-8.1.0-1.el8.x86_64
	libtirpc-devel is needed by mysql-community-8.1.0-1.el8.x86_64
	ncurses-devel is needed by mysql-community-8.1.0-1.el8.x86_64
	numactl-devel is needed by mysql-community-8.1.0-1.el8.x86_64
	openldap-devel is needed by mysql-community-8.1.0-1.el8.x86_64
	perl is needed by mysql-community-8.1.0-1.el8.x86_64
	perl(Env) is needed by mysql-community-8.1.0-1.el8.x86_64
	perl(JSON) is needed by mysql-community-8.1.0-1.el8.x86_64
	perl(Memoize) is needed by mysql-community-8.1.0-1.el8.x86_64
	perl(Time::HiRes) is needed by mysql-community-8.1.0-1.el8.x86_64
	rpcgen is needed by mysql-community-8.1.0-1.el8.x86_64

So let’s start by installing those packages:

$ sudo dnf install -y cmake cyrus-sasl-devel gcc-toolset-12-annobin-annocheck \                      
                gcc-toolset-12-annobin-plugin-gcc libaio-devel libtirpc-devel \
                ncurses-devel numactl-devel openldap-devel  perl perl-JSON \
                perl-Env perl-Memoize 
$ sudo dnf install -y https://yum.oracle.com/repo/OracleLinux/OL8/codeready/builder/x86_64/getPackage/rpcgen-1.3.1-4.el8.x86_64.rpm

We also need to install the following two packages:

$ sudo dnf install -y systemd-devel curl-devel

Building RPMs

Now we are ready to build all the rpms from the source package. This is the command to rebuild everything for the version you want:

$ rpmbuild --rebuild mysql-community-8.1.0-1.el8.src.rpm

When done, all the new rpms can be found in ~/rpmbuild/RPMS/x86_64/:

$ ls -lh ~opc/rpmbuild/RPMS/x86_64/
total 966M
-rw-rw-r--. 1 opc opc  17M Aug 19 12:40 mysql-community-client-8.1.0-1.el8.x86_64.rpm
-rw-rw-r--. 1 opc opc  36M Aug 19 12:44 mysql-community-client-debuginfo-8.1.0-1.el8.x86_64.rpm
-rw-rw-r--. 1 opc opc 3.6M Aug 19 12:41 mysql-community-client-plugins-8.1.0-1.el8.x86_64.rpm
-rw-rw-r--. 1 opc opc 4.3M Aug 19 12:44 mysql-community-client-plugins-debuginfo-8.1.0-1.el8.x86_64.rpm
-rw-rw-r--. 1 opc opc 671K Aug 19 12:40 mysql-community-common-8.1.0-1.el8.x86_64.rpm
-rw-rw-r--. 1 opc opc 3.3M Aug 19 12:42 mysql-community-debuginfo-8.1.0-1.el8.x86_64.rpm
-rw-rw-r--. 1 opc opc  25M Aug 19 12:42 mysql-community-debugsource-8.1.0-1.el8.x86_64.rpm
-rw-rw-r--. 1 opc opc 2.3M Aug 19 12:41 mysql-community-devel-8.1.0-1.el8.x86_64.rpm
-rw-rw-r--. 1 opc opc 2.3M Aug 19 12:40 mysql-community-icu-data-files-8.1.0-1.el8.x86_64.rpm
-rw-rw-r--. 1 opc opc 1.6M Aug 19 12:41 mysql-community-libs-8.1.0-1.el8.x86_64.rpm
-rw-rw-r--. 1 opc opc 3.0M Aug 19 12:44 mysql-community-libs-debuginfo-8.1.0-1.el8.x86_64.rpm
-rw-rw-r--. 1 opc opc  36M Aug 19 12:39 mysql-community-server-8.1.0-1.el8.x86_64.rpm
-rw-rw-r--. 1 opc opc  27M Aug 19 12:40 mysql-community-server-debug-8.1.0-1.el8.x86_64.rpm
-rw-rw-r--. 1 opc opc 126M Aug 19 12:44 mysql-community-server-debug-debuginfo-8.1.0-1.el8.x86_64.rpm
-rw-rw-r--. 1 opc opc 242M Aug 19 12:43 mysql-community-server-debuginfo-8.1.0-1.el8.x86_64.rpm
-rw-rw-r--. 1 opc opc 363M Aug 19 12:41 mysql-community-test-8.1.0-1.el8.x86_64.rpm
-rw-rw-r--. 1 opc opc  28M Aug 19 12:44 mysql-community-test-debuginfo-8.1.0-1.el8.x86_64.rpm
-rw-rw-r--. 1 opc opc 5.2M Aug 19 12:41 mysql-router-community-8.1.0-1.el8.x86_64.rpm
-rw-rw-r--. 1 opc opc  45M Aug 19 12:44 mysql-router-community-debuginfo-8.1.0-1.el8.x86_64.rpm

And voilà !

Once again, this is not too trivial when we know how it works and what are the right dependencies.

As usual, enjoy MySQL !

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

As MySQL Community Manager, I am an employee of Oracle and the views expressed on this blog are my own and do not necessarily reflect the views of Oracle.

You can find articles I wrote on Oracle’s blog.