July 14, 2015

Installing Custom MySQL Versions

If at all possible, you should use WHM to install MySQL, however, if you need a version of MySQL outside of what they are offering in current cPanel versions, it is possible to install your own versions.
These instructions can also be used to install MariaDB!  For more info on this, see cPanel’s blog.
It should be noted that some versions of cPanel do not officially support certain versions of MySQL, or installing MySQL in the fashion that is about to be described.  So do this at your own risk! Going to a minor version that is not supported by cPanel may also prevent cPanel updates from running at all.

Make Backups

If this is on a live system, make sure to make backups of the databases.
mkdir /root/dbbackups
touch /root/dbbackups/list
for db in `mysql -e 'show databases' |awk '{print $1}' | grep -v Database` ; do
    mysqldump --add-drop-table $db > /root/dbbackups/$db.sql && echo $db >> list
done

Download Packages

Download the binaries for the OS version and MySQL version you are using from the cPanel repo.  You can find MySQL packages on these sites:
You can also download the RPMs from MySQL’s website – though it’s not officially supported by cPanel, using the vendor RPM seems to work just fine.

Break up cPanel and MySQL

Now, you need to tell cPanel not to try to manage MySQL binaries anymore:
/scripts/update_local_rpm_versions –edit target_settings.MySQL50 unmanaged
/scripts/update_local_rpm_versions –edit target_settings.MySQL51 unmanaged
/scripts/update_local_rpm_versions –edit target_settings.MySQL55 unmanaged
/scripts/update_local_rpm_versions –edit target_settings.MySQL56 unmanaged

Uninstall Existing MySQL

To remove existing MySQL packages from the server:
/scripts/check_cpanel_rpms –fix –targets=MySQL50,MySQL51,MySQL55,MySQL56

Install New MySQL Packages

Go back to where you downloaded the packages to on your server, and install them:
rpm -Uvh mysql-*
Then check to see that the new version is indeed installed:
root@server [~]# mysql -V
mysql  Ver 14.14 Distrib 5.5.35, for Linux (x86_64) using readline 5.1
If you moved between minor versions (ie, 5.1 to 5.5), you should also run:
mysql_upgrade
You may also need to run EasyApache if PHP ceases to function.  However, you can get around this by copying the MySQL client libraries from /usr/lib[64] to another location before upgrading, then moving them back afterwards.  This is only a band-aid though, and should only be used to allow enough time to recompile PHP.

0 comments:

Post a Comment