MySQL & MariaDB RPMs on Enterprise Linux 6

We’ve had a number of questions from customers lately about a change in Enterprise Linux 6 that introduces compatibility problems between older vendor RPMs (those from dev.mysql.com or Monty Program AB, for instance) and newer OS packages (the ones available from the OS distribution’s package repository). Specifically, there is a new “mysql-libs” package that some other EL packages require. In particular, postfix requires mysql-libs, any many packages require postfix, which is the default MTA in EL6. MySQL and MariaDB Packages built for older Enterprise Linux versions (4 or 5) to not provide the “mysql-libs” capability, which means that installing them will not satisfy that requirement for other packages. EL6 includes MySQL 5.1, which had an older version of the client library than MySQL 5.5 has, so we will be looking at the “shared-compat” and “compat” packages instead of the “shared” package. The “shared-compat” and “compat” packages include older versions of the client libraries to provide compatibility with software built and linked during a bygone era. Early MySQL 5.5 shared-compat packages, built by the MySQL build team at Oracle (these are the ones from dev.mysql.com), specifically labeled for Oracle Linux 6, did not provide the “mysql-libs” capability, which had the curious effect of preventing them from functioning properly for the company’s own Linux distribution. That has been fixed in newer MySQL 5.5 RPMs available from dev.mysql.com and in the MariaDB EL6 RPMs (they’re labeled CentOS 6) available at mariadb.org. Here is a look at the capabilities provided by the mysql-libs RPM available from the OS’s package repository:

$ repoquery -q --provides mysql-libs
config(mysql-libs) = 5.1.61-1.el6_2.1
libmysqlclient.so.16
libmysqlclient.so.16(libmysqlclient_16)
libmysqlclient_r.so.16
libmysqlclient_r.so.16(libmysqlclient_16)
mysql-libs = 5.1.61-1.el6_2.1
mysql-libs(x86-32) = 5.1.61-1.el6_2.1
config(mysql-libs) = 5.1.61-1.el6_2.1
libmysqlclient.so.16()(64bit)
libmysqlclient.so.16(libmysqlclient_16)(64bit)
libmysqlclient_r.so.16()(64bit)
libmysqlclient_r.so.16(libmysqlclient_16)(64bit)
mysql-libs = 5.1.61-1.el6_2.1
mysql-libs(x86-64) = 5.1.61-1.el6_2.1

And here are the capabilities provided by early Oracle MySQL 5.5 RPMs, specifically targeted for EL6:

$ rpm -qp --provides MySQL-shared-compat-5.5.21-1.el6.x86_64.rpm 
MySQL-shared  
libmysqlclient.so.12()(64bit)  
libmysqlclient.so.14()(64bit)  
libmysqlclient.so.14(libmysqlclient_14)(64bit)  
libmysqlclient.so.15()(64bit)  
libmysqlclient.so.15(libmysqlclient_15)(64bit)  
libmysqlclient.so.16()(64bit)  
libmysqlclient.so.16(libmysqlclient_16)(64bit)  
libmysqlclient_r.so.12()(64bit)  
libmysqlclient_r.so.14()(64bit)  
libmysqlclient_r.so.14(libmysqlclient_14)(64bit)  
libmysqlclient_r.so.15()(64bit)  
libmysqlclient_r.so.15(libmysqlclient_15)(64bit)  
libmysqlclient_r.so.16()(64bit)  
libmysqlclient_r.so.16(libmysqlclient_16)(64bit)  
MySQL-shared-compat = 5.5.21-1.el6
MySQL-shared-compat(x86-64) = 5.5.21-1.el6

When you try to install the set of MySQL 5.5.21 RPMs, all seems to go well, but it’s not so pretty when you try installing something like postfix that requires mysql-libs:

$ sudo rpm -i MySQL-server-5.5.21-1.el6.x86_64.rpm MySQL-shared-5.5.21-1.el6.x86_64.rpm MySQL-client-5.5.21-1.el6.x86_64.rpm MySQL-shared-compat-5.5.21-1.el6.x86_64.rpm

$ sudo yum install postfix
Loaded plugins: fastestmirror, presto
Loading mirror speeds from cached hostfile
 * base: centos.mirror.freedomvoice.com
 * extras: mirror.hmc.edu
 * updates: mirrors.ecvps.com
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package postfix.x86_64 2:2.6.6-2.2.el6_1 will be installed
--> Processing Dependency: mysql-libs for package: 2:postfix-2.6.6-2.2.el6_1.x86_64
--> Running transaction check
---> Package mysql-libs.x86_64 0:5.1.61-1.el6_2.1 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

==============================================================================================================================================================
 Package                              Arch                             Version                                        Repository                         Size
==============================================================================================================================================================
Installing:
 postfix                              x86_64                           2:2.6.6-2.2.el6_1                              base                              2.0 M
Installing for dependencies:
 mysql-libs                           x86_64                           5.1.61-1.el6_2.1                               updates                           1.2 M

Transaction Summary
==============================================================================================================================================================
Install       2 Package(s)

Total size: 3.3 M
Total download size: 2.0 M
Installed size: 14 M
Is this ok [y/N]: y
Downloading Packages:
Setting up and reading Presto delta metadata
Processing delta metadata
Package(s) data still to download: 2.0 M
postfix-2.6.6-2.2.el6_1.x86_64.rpm                                                                                                     | 2.0 MB     00:04     
Running rpm_check_debug
Running Transaction Test


Transaction Check Error:
  file /usr/share/mysql/czech/errmsg.sys from install of mysql-libs-5.1.61-1.el6_2.1.x86_64 conflicts with file from package MySQL-server-5.5.21-1.el6.x86_64
  file /usr/share/mysql/danish/errmsg.sys from install of mysql-libs-5.1.61-1.el6_2.1.x86_64 conflicts with file from package MySQL-server-5.5.21-1.el6.x86_64
  file /usr/share/mysql/dutch/errmsg.sys from install of mysql-libs-5.1.61-1.el6_2.1.x86_64 conflicts with file from package MySQL-server-5.5.21-1.el6.x86_64
  file /usr/share/mysql/english/errmsg.sys from install of mysql-libs-5.1.61-1.el6_2.1.x86_64 conflicts with file from package MySQL-server-5.5.21-1.el6.x86_64
  file /usr/share/mysql/estonian/errmsg.sys from install of mysql-libs-5.1.61-1.el6_2.1.x86_64 conflicts with file from package MySQL-server-5.5.21-1.el6.x86_64
  file /usr/share/mysql/french/errmsg.sys from install of mysql-libs-5.1.61-1.el6_2.1.x86_64 conflicts with file from package MySQL-server-5.5.21-1.el6.x86_64
  file /usr/share/mysql/german/errmsg.sys from install of mysql-libs-5.1.61-1.el6_2.1.x86_64 conflicts with file from package MySQL-server-5.5.21-1.el6.x86_64
  file /usr/share/mysql/greek/errmsg.sys from install of mysql-libs-5.1.61-1.el6_2.1.x86_64 conflicts with file from package MySQL-server-5.5.21-1.el6.x86_64
  file /usr/share/mysql/hungarian/errmsg.sys from install of mysql-libs-5.1.61-1.el6_2.1.x86_64 conflicts with file from package MySQL-server-5.5.21-1.el6.x86_64
  file /usr/share/mysql/italian/errmsg.sys from install of mysql-libs-5.1.61-1.el6_2.1.x86_64 conflicts with file from package MySQL-server-5.5.21-1.el6.x86_64
  file /usr/share/mysql/japanese/errmsg.sys from install of mysql-libs-5.1.61-1.el6_2.1.x86_64 conflicts with file from package MySQL-server-5.5.21-1.el6.x86_64
  file /usr/share/mysql/korean/errmsg.sys from install of mysql-libs-5.1.61-1.el6_2.1.x86_64 conflicts with file from package MySQL-server-5.5.21-1.el6.x86_64
  file /usr/share/mysql/norwegian-ny/errmsg.sys from install of mysql-libs-5.1.61-1.el6_2.1.x86_64 conflicts with file from package MySQL-server-5.5.21-1.el6.x86_64
  file /usr/share/mysql/norwegian/errmsg.sys from install of mysql-libs-5.1.61-1.el6_2.1.x86_64 conflicts with file from package MySQL-server-5.5.21-1.el6.x86_64
  file /usr/share/mysql/polish/errmsg.sys from install of mysql-libs-5.1.61-1.el6_2.1.x86_64 conflicts with file from package MySQL-server-5.5.21-1.el6.x86_64
  file /usr/share/mysql/portuguese/errmsg.sys from install of mysql-libs-5.1.61-1.el6_2.1.x86_64 conflicts with file from package MySQL-server-5.5.21-1.el6.x86_64
  file /usr/share/mysql/romanian/errmsg.sys from install of mysql-libs-5.1.61-1.el6_2.1.x86_64 conflicts with file from package MySQL-server-5.5.21-1.el6.x86_64
  file /usr/share/mysql/russian/errmsg.sys from install of mysql-libs-5.1.61-1.el6_2.1.x86_64 conflicts with file from package MySQL-server-5.5.21-1.el6.x86_64
  file /usr/share/mysql/serbian/errmsg.sys from install of mysql-libs-5.1.61-1.el6_2.1.x86_64 conflicts with file from package MySQL-server-5.5.21-1.el6.x86_64
  file /usr/share/mysql/slovak/errmsg.sys from install of mysql-libs-5.1.61-1.el6_2.1.x86_64 conflicts with file from package MySQL-server-5.5.21-1.el6.x86_64
  file /usr/share/mysql/spanish/errmsg.sys from install of mysql-libs-5.1.61-1.el6_2.1.x86_64 conflicts with file from package MySQL-server-5.5.21-1.el6.x86_64
  file /usr/share/mysql/swedish/errmsg.sys from install of mysql-libs-5.1.61-1.el6_2.1.x86_64 conflicts with file from package MySQL-server-5.5.21-1.el6.x86_64
  file /usr/share/mysql/ukrainian/errmsg.sys from install of mysql-libs-5.1.61-1.el6_2.1.x86_64 conflicts with file from package MySQL-server-5.5.21-1.el6.x86_64

Error Summary
-------------

As you can see, an attempt to install postfix results in the package manager trying to install mysql-libs, which conflicts (somewhat unintuitively) with MySQL-server. And postfix is not the only one; you can use repoquery --whatrequires mysql-libs to get a list of the EL6 packages that require mysql-libs. Fortunately, improvements were made to Oracle’s MySQL packaging and the newer MySQL 5.5 shared-compat RPM provides mysql-libs:

$ rpm -qp --provides MySQL-shared-compat-5.5.25-1.el6.x86_64.rpm 
libmysqlclient.so.12()(64bit)  
libmysqlclient.so.14()(64bit)  
libmysqlclient.so.14(libmysqlclient_14)(64bit)  
libmysqlclient.so.15()(64bit)  
libmysqlclient.so.15(libmysqlclient_15)(64bit)  
libmysqlclient.so.16()(64bit)  
libmysqlclient.so.16(libmysqlclient_16)(64bit)  
libmysqlclient_r.so.12()(64bit)  
libmysqlclient_r.so.14()(64bit)  
libmysqlclient_r.so.14(libmysqlclient_14)(64bit)  
libmysqlclient_r.so.15()(64bit)  
libmysqlclient_r.so.15(libmysqlclient_15)(64bit)  
libmysqlclient_r.so.16()(64bit)  
libmysqlclient_r.so.16(libmysqlclient_16)(64bit)  
mysql-libs  
MySQL-shared-compat = 5.5.25-1.el6
MySQL-shared-compat(x86-64) = 5.5.25-1.el6

The MariaDB 5.5 shared-compat RPM also provides the mysql-libs capability, though you may notice that it provides fewer legacy client libraries and the package filename is different (the version number of in a different place and it’s “compat” instead of “shared-compat”):

$ rpm -qp --provides MariaDB-5.5.24-centos6-x86_64-compat.rpm 
libmysqlclient.so.15()(64bit)  
libmysqlclient.so.15(libmysqlclient_15)(64bit)  
libmysqlclient.so.16()(64bit)  
libmysqlclient.so.16(libmysqlclient_16)(64bit)  
libmysqlclient_r.so.15()(64bit)  
libmysqlclient_r.so.15(libmysqlclient_15)(64bit)  
libmysqlclient_r.so.16()(64bit)  
libmysqlclient_r.so.16(libmysqlclient_16)(64bit)  
mysql-libs = 5.3.5
MariaDB-compat = 5.5.24-1
MariaDB-compat(x86-64) = 5.5.24-1

Using these MariaDB RPMs that provide “mysql-libs” allows a painless installation of postfix:

$ sudo rpm -i MariaDB-5.5.24-centos6-x86_64-{client,common,compat,server,shared}.rpm
  ...

$ sudo yum install postfix
Loaded plugins: fastestmirror, presto
Loading mirror speeds from cached hostfile
 * base: pubmirrors.reflected.net
 * extras: mirror.hmc.edu
 * updates: mirrors.ecvps.com
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package postfix.x86_64 2:2.6.6-2.2.el6_1 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

==============================================================================================================================================================
 Package                             Arch                               Version                                        Repository                        Size
==============================================================================================================================================================
Installing:
 postfix                             x86_64                             2:2.6.6-2.2.el6_1                              base                             2.0 M

Transaction Summary
==============================================================================================================================================================
Install       1 Package(s)

Total size: 2.0 M
Installed size: 9.7 M
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Warning: RPMDB altered outside of yum.
  Installing : 2:postfix-2.6.6-2.2.el6_1.x86_64                                                                                                           1/1 

Installed:
  postfix.x86_64 2:2.6.6-2.2.el6_1                                                                                                                            

Complete!

We can see the postfix requires mysql-libs and that this requirement is being satisfied by the MariaDB-compat package:

$ rpm -q --whatrequires mysql-libs
postfix-2.6.6-2.2.el6_1.x86_64
$ rpm -q --whatprovides mysql-libs
MariaDB-compat-5.5.24-1.x86_64

If, for some reason, you want to use an older set of RPMs that do not provide the mysql-libs capability, it’s a bit more tricky. You can use –force and –nodeps to ignore the problem, but that can cause lots of messy headaches. I created a stub RPM that provides mysql-libs and requires libmysqlclient.so.16. It requires that specific version of the client library because that’s version of the MySQL client library that “native” EL6 apps will be linked against, and that file will be provided by different packages depending on the version of MariaDB or MySQL you’re working with. For MySQL 5.1 or MariaDB 5.2 or 5.3, libmysqlclient.so.16 is provided by the “shared” RPM but for MySQL 5.5 and MariaDB 5.5 it is provided by the “shared-compat” and “compat” RPMs, respectively. Here’s the spec file for my mysql-libs-stub RPM:

$ cat mysql-libs-stub.spec 
Name:   mysql-libs-stub 
Version:        0.3
Release:        1%{?dist}
Summary:        Provides mysql-libs capability to comply with EL6 expectations. Requires mysql-shared (MariaDB-shared suffices, of course).

Group:          SkySQL, AB
License:        GPL

BuildArch: noarch

Requires:       mysql-shared
Provides:       mysql-libs

%description
Stub package to provide the mysql-libs capability.

%files

Building this into an actual RPM is pretty easy:

$ rpmbuild -bb mysql-libs-stub.spec 
Processing files: mysql-libs-stub-0.3-1.el6.noarch
Checking for unpackaged file(s): /usr/lib/rpm/check-files /home/kolbe/rpmbuild/BUILDROOT/mysql-libs-stub-0.3-1.el6.x86_64
Wrote: /home/kolbe/rpmbuild/RPMS/noarch/mysql-libs-stub-0.3-1.el6.noarch.rpm
Executing(%clean): /bin/sh -e /var/tmp/rpm-tmp.ummP7P
+ umask 022
+ cd /home/kolbe/rpmbuild/BUILD
+ /bin/rm -rf /home/kolbe/rpmbuild/BUILDROOT/mysql-libs-stub-0.3-1.el6.x86_64
+ exit 0

$ rpm -qp --provides rpmbuild/RPMS/noarch/mysql-libs-stub-0.3-1.el6.noarch.rpm 
mysql-libs  
mysql-libs-stub = 0.3-1.el6

$ rpm -qp --requires rpmbuild/RPMS/noarch/mysql-libs-stub-0.3-1.el6.noarch.rpm 
mysql-shared
rpmlib(PayloadFilesHavePrefix) <= 4.0-1
rpmlib(CompressedFileNames) <= 3.0.4-1

Here’s what it looks like to install MariaDB 5.3.5 RPMs, then my mysql-libs-stub RPM, and finally postfix:

$ sudo rpm -i MariaDB-{client,server,shared}-5.3.5*
  ...

$ sudo rpm -i mysql-libs-stub-0.3-1.el6.noarch.rpm

$ sudo yum install postfix
Loaded plugins: fastestmirror, presto
Loading mirror speeds from cached hostfile
 * base: linux.mirrors.es.net
 * extras: mirror.hmc.edu
 * updates: mirrors.ecvps.com
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package postfix.x86_64 2:2.6.6-2.2.el6_1 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

==============================================================================================================================================================
 Package                             Arch                               Version                                        Repository                        Size
==============================================================================================================================================================
Installing:
 postfix                             x86_64                             2:2.6.6-2.2.el6_1                              base                             2.0 M

Transaction Summary
==============================================================================================================================================================
Install       1 Package(s)

Total download size: 2.0 M
Installed size: 9.7 M
Is this ok [y/N]: y
Downloading Packages:
Setting up and reading Presto delta metadata
Processing delta metadata
Package(s) data still to download: 2.0 M
postfix-2.6.6-2.2.el6_1.x86_64.rpm                                                                                                     | 2.0 MB     00:01     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Warning: RPMDB altered outside of yum.
  Installing : 2:postfix-2.6.6-2.2.el6_1.x86_64                                                                                                           1/1 

Installed:
  postfix.x86_64 2:2.6.6-2.2.el6_1                                                                                                                            

Complete!

And we can now see that MariaDB 5.3.5 is installed alongside my mysql-libs-stub RPM, which in turn fulfills postfix’s mysql-libs requirement:

$ rpm -qa | grep MariaDB
MariaDB-shared-5.3.5-113.el5.x86_64
MariaDB-server-5.3.5-113.el5.x86_64
MariaDB-client-5.3.5-113.el5.x86_64
[kolbe@db1 ~]$ rpm -qa | grep mysql-libs-stub
mysql-libs-stub-0.3-1.el6.noarch
[kolbe@db1 ~]$ rpm -q --requires mysql-libs-stub
mysql-shared  
rpmlib(PayloadFilesHavePrefix) <= 4.0-1
rpmlib(CompressedFileNames) <= 3.0.4-1
[kolbe@db1 ~]$ rpm -q --whatprovides mysql-shared
MariaDB-shared-5.3.5-113.el5.x86_64
[kolbe@db1 ~]$ rpm -q --whatrequires mysql-libs
postfix-2.6.6-2.2.el6_1.x86_64
[kolbe@db1 ~]$ rpm -q --whatprovides mysql-libs
mysql-libs-stub-0.3-1.el6.noarch

This is far from a foolproof solution, but it allows the installation of older MySQL and MariaDB RPMs on Enterprise Linux 6 without having to resort to forcing installations or ignoring dependencies. I’d be interested to know what you think of this approach or if you find this useful.