Installing MySQL 4 RPMs on AMD64 x86 64

From Dev411: The Code Wiki

Although up2date and yum provide x64_64 RPMs for Redhat Enterprise Linux (RHEL 4) and CentOS 4, sometimes you just want to install the RPMs from MySQL.com. Unfortunately the RPMs on MySQL.com are not compiled correctly because they don't use -fPID for libmysqlclient.a which causes compiling PHP to crash. This is MySQL bug #13159.

To rebuild MySQL with -fPIC, we need to edit /usr/lib/rpm/rpmrc and add -fPIC to the x86_64 line. rpmrc needs to be copied to /etc/rpmrc to take effect.

optflags: x86_64 -O3 -g -pipe -fPIC -m64

Now that -fPIC is enabled, rebuild RPMs from the SRPM:

# yum install gperf
# rpmbuild --rebuild MySQL-standard-4.1.18-0.rhel4.src.rpm

Instead of editing rpmrc, you can also define -fPIC with rpmbuild's --define option:

rpmbuild --rebuild --define "__global_cflags -O3 -g -pipe \
-fPIC -m64" MySQL-standard-4.1.18-0.rhel4.src.rpm

RHEL4 / CentOS 4.2 come installed with SELinux which needs to be configured (or disabled) for MySQL's init.d script to automatically start up MySQL. SELinux start up configuration is held in /etc/sysconfig/selinux. To configure SELinux for MySQL without permanently disabling it, use setenforce and restorecon. MySQL-devel is needed to create /usr/bin/mysql_config which is required by DBD::mysql and PHP's mysqli. On x86_64 it's also necessary to symlink /usr/lib64/mysql to /usr/lib/mysql in order for PHP to build with --with-mysql which is required by MediaWiki 1.5.7.

# cd /usr/src/redhat/RPMS/x86_64
# setenforce 0
# rpm -ivh MySQL-shared-standard-4.1.18-0.rhel4.x86_64.rpm
# rpm -ivh MySQL-client-standard-4.1.18-0.rhel4.x86_64.rpm --nodeps
# rpm -ivh MySQL-server-standard-4.1.18-0.rhel4.x86_64.rpm --nodeps
# rpm -ivh MySQL-devel-standard-4.1.18-0.rhel4.x86_64.rpm
# restorecon -R /var/lib/mysql
# setenforce 1
# ln -s /usr/lib64/mysql /usr/lib/mysql
The x86_64 version of MySQL-client has a dependency on Perl's DBI module. Building from the SRPM results in a MySQL-client and MySQL-server RPMs that require a RPM perl in /usr/local/bin/perl even if there is already a perl interpreter there. The installer won't recognize a CPAN-installed DBI so a RPM is necessary. The other option is to install with --nodeps. This has been confirmed to be an acceptable solution on MySQL.com's bug tracker.

Once your RPMs have been rebuilt with -fPIC you should be able to intsall them as usual and be on your way.