Installing Custom MySQL Versions

Rate this post

Update 2/14/14: These instructions have been updated to apply to 11.36+.

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:

http://httpupdate.cpanel.net/RPM/11.36/ (For versions 11.36+)
http://httpupdate.cpanel.net/pub/mysqlinstall/ (legacy versions)

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.

Don't be selfish, share!Tweet about this on TwitterShare on RedditShare on TumblrBuffer this pageDigg thisShare on FacebookFlattr the authorEmail this to someoneShare on Google+Pin on PinterestPrint this pageShare on LinkedInShare on StumbleUpon

3 Comments

  1. Pingback: Upgrading or Downgrading MySQL :: The cPanel Admin

  2. Kenneth Reply

    This is a nice article. There are, however, a few things I’d like to point out (in no particular order):

    1. touch /etc/mysqlupdisable. You can also do this in /etc/cpupdate.conf, by changing or adding MYSQLUP=never

    2. I’d recommend moving /etc/my.cnf out of the way. Depending upon which version of MySQL you are installing, if you have a customized /etc/my.cnf file, it is quite possible for entries therein to cause complications during the install.

    This happened to me recently in a test upgrade to MySQL 5.5. That version deprecated some directives I had in /etc/my.cnf. Their presence caused mysqld to fail to start during the install of MySQL-server. This in turn caused a chicken-and-egg problem in getting the system tables upgraded properly.

    Moving /etc/my.cnf out of the way during the upgrade will prevent those types of problems. After the upgrade you can put /etc/my.cnf back in place. This allows you to deal with directive deprecation in a safer manner.

    3. Reinstalling Bundle::DBD::mysql should not be necessary. /scripts/mysqlup does this after installing MySQL.

    4. You may also need to recompile the PHP binaries used by Apache (/scripts/easyapache). Especially is this true if you are changing MySQL versions (e.g. 4.1 -> 5.1)

    5. I highly recommend that if you are simply wanting to change the MySQL version (4.1 -> 5.1) to use the MySQL Upgrade interface in WHM. This ui automates rebuilding of PHP, reinstalling the Ruby extensions, and many more things.

    6. The URL for the cPanel MySQL RPMs is incorrect. The correct URL is http://httpupdate.cpanel.net/pub/mysqlinstall. This URL is only correct for cPanel & WHM version 11.28 and older. 11.30 and newer use a new system for retrieving the RPMs (still wrapped up in mysqlup tho).

  3. Pingback: » Upgrading to MySQL 5.1.x on cPanel :: v-nessa.net :: Programming is Sexy

Leave a Reply

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

Log in