Recently I had to upgrade MySQL on a cPanel server. Although this can be easily done from within WHM itself I wanted to perform this from the commandline as that is more my way of working. The documentation on upgrading MySQL from the commandline on a cPanel server is not easily found, that’s why I want to share these instructions here.
Important notice:
Be aware that after upgrading MySQL you need to recompile PHP as well if you want the MySQL extension to work with the upgraded MySQL version. The recompile of PHP can be done using the EasyApache option from within WHM or /scripts/easyapache.
Changing the cPanel configuration file:
In order to upgrade MySQL we need to alter the cPanel configuration file. Log in via SSH as the root user and open the following configuration file:
vim /var/cpanel/cpanel.config
Search for the line starting with:
mysql-version=
In my case the server was running MySQL 5.5, so the line looked like this:
mysql-version=5.5
I want to upgrade to MySQL 5.6, so change the line to (for this example):
mysql-version=5.6
Save the changes.
Upgrading MySQL:
Since the configuration is changed, we need to make sure cPanel sees the change and downloads the correct RPM’s for MySQL and install it. Run the following command (the output of the command is underneath it):
/scripts/check_cpanel_rpms
[2016-06-01 10:26:01 +0200]
[2016-06-01 10:26:01 +0200] Problems were detected with cPanel-provided files which are RPM controlled.
[2016-06-01 10:26:01 +0200] If you did not make these changes intentionally, you can correct them by running:
[2016-06-01 10:26:01 +0200]
[2016-06-01 10:26:01 +0200] > /usr/local/cpanel/scripts/check_cpanel_rpms --fix
[2016-06-01 10:26:01 +0200] The following RPMs are missing from your system:
[2016-06-01 10:26:01 +0200] MySQL56-client-5.6.30-1.cp1156
[2016-06-01 10:26:01 +0200] MySQL56-devel-5.6.30-1.cp1156
[2016-06-01 10:26:01 +0200] MySQL56-server-5.6.30-1.cp1156
[2016-06-01 10:26:01 +0200] MySQL56-shared-5.6.30-1.cp1156
[2016-06-01 10:26:01 +0200] MySQL56-test-5.6.30-1.cp1156
[2016-06-01 10:26:03 +0200]
[2016-06-01 10:26:03 +0200] The following RPMs are unneeded on your system and should be uninstalled:
[2016-06-01 10:26:03 +0200] MySQL55-client-5.5.49-1.cp1156
[2016-06-01 10:26:03 +0200] MySQL55-devel-5.5.49-1.cp1156
[2016-06-01 10:26:03 +0200] MySQL55-server-5.5.49-1.cp1156
[2016-06-01 10:26:03 +0200] MySQL55-shared-5.5.49-1.cp1156
[2016-06-01 10:26:03 +0200] MySQL55-test-5.5.49-1.cp1156
Do you want to repair these RPMs?(y/n):
It’s wise to check the versions above before performing the upgrade, make sure that the new version matches the one you set and that the old version is the version you are currently running. If everything is correct we can start the upgrade by saying yes here and the upgrade will start:
y
[2016-06-01 10:51:49 +0200] Removing 0 broken rpms:
[2016-06-01 10:51:49 +0200] rpm: no packages given for erase
[2016-06-01 10:51:50 +0200] Downloading http://httpupdate.cpanel.net/RPM/11.56/centos/6/x86_64/rpm.sha512
[2016-06-01 10:51:50 +0200] Successfully verified signature for cpanel (key types: release).
[2016-06-01 10:51:50 +0200] Downloading http://httpupdate.cpanel.net/RPM/11.56/centos/6/x86_64/MySQL56-shared-5.6.30-1.cp1156.x86_64.rpm
[2016-06-01 10:51:50 +0200] Downloading http://httpupdate.cpanel.net/RPM/11.56/centos/6/x86_64/MySQL56-server-5.6.30-1.cp1156.x86_64.rpm
[2016-06-01 10:51:51 +0200] Downloading http://httpupdate.cpanel.net/RPM/11.56/centos/6/x86_64/MySQL56-client-5.6.30-1.cp1156.x86_64.rpm
[2016-06-01 10:51:51 +0200] Downloading http://httpupdate.cpanel.net/RPM/11.56/centos/6/x86_64/MySQL56-devel-5.6.30-1.cp1156.x86_64.rpm
[2016-06-01 10:51:51 +0200] Downloading http://httpupdate.cpanel.net/RPM/11.56/centos/6/x86_64/MySQL56-test-5.6.30-1.cp1156.x86_64.rpm
[2016-06-01 10:51:52 +0200] Disabling service monitoring.
[2016-06-01 10:51:57 +0200] Hooks system enabled.
[2016-06-01 10:51:57 +0200] Checking for and running RPM::Versions 'pre' hooks for any RPMs about to be installed
[2016-06-01 10:51:57 +0200] All required 'pre' hooks have been run
[2016-06-01 10:51:58 +0200] Uninstalling unneeded rpms: MySQL55-server MySQL55-devel MySQL55-test MySQL55-shared MySQL55-client
[2016-06-01 10:52:22 +0200] Installing new rpms: MySQL56-client-5.6.30-1.cp1156.x86_64.rpm MySQL56-devel-5.6.30-1.cp1156.x86_64.rpm MySQL56-server-5.6.30-1.cp1156.x86_64.rpm MySQL56-shared-5.6.30-1.cp1156.x86_64.rpm MySQL56-test-5.6.30-1.cp1156.x86_64.rpm
[2016-06-01 10:52:22 +0200] Preparing packages for installation...
[2016-06-01 10:52:23 +0200] MySQL56-client-5.6.30-1.cp1156
[2016-06-01 10:52:23 +0200] MySQL56-test-5.6.30-1.cp1156
[2016-06-01 10:52:30 +0200] MySQL56-devel-5.6.30-1.cp1156
[2016-06-01 10:52:30 +0200] Giving mysqld 5 seconds to exit nicely
[2016-06-01 10:52:36 +0200] MySQL56-server-5.6.30-1.cp1156
[2016-06-01 10:52:57 +0200] Waiting for “mysql” to start ……waiting for “mysql” to initialize ………finished.
[2016-06-01 10:52:57 +0200]
[2016-06-01 10:52:57 +0200] Startup Log
[2016-06-01 10:52:57 +0200] Starting MySQL..... SUCCESS!
[2016-06-01 10:52:57 +0200]
[2016-06-01 10:52:57 +0200] Log Messages
[2016-06-01 10:52:57 +0200] 2016-06-01 10:52:56 30359 [Note] /usr/sbin/mysqld: ready for connections.
[2016-06-01 10:52:57 +0200]
[2016-06-01 10:52:57 +0200] mysql started successfully.
[2016-06-01 10:55:44 +0200] Looking for 'mysql' as: /usr/bin/mysql
[2016-06-01 10:55:44 +0200] Looking for 'mysqlcheck' as: /usr/bin/mysqlcheck
[2016-06-01 10:55:44 +0200] Running 'mysqlcheck with default connection arguments
[2016-06-01 10:55:44 +0200] Running 'mysqlcheck with default connection arguments
[2016-06-01 10:55:44 +0200] mysql.columns_priv OK
[2016-06-01 10:55:44 +0200] mysql.db OK
[2016-06-01 10:55:44 +0200] mysql.event OK
[2016-06-01 10:55:44 +0200] mysql.func OK
[2016-06-01 10:55:44 +0200] mysql.general_log OK
[2016-06-01 10:55:44 +0200] mysql.help_category OK
[2016-06-01 10:55:44 +0200] mysql.help_keyword OK
[2016-06-01 10:55:44 +0200] mysql.help_relation OK
[2016-06-01 10:55:44 +0200] mysql.help_topic OK
[2016-06-01 10:55:44 +0200] mysql.host OK
[2016-06-01 10:55:44 +0200] mysql.ndb_binlog_index OK
[2016-06-01 10:55:44 +0200] mysql.plugin OK
[2016-06-01 10:55:44 +0200] mysql.proc OK
[2016-06-01 10:55:44 +0200] mysql.procs_priv OK
[2016-06-01 10:55:44 +0200] mysql.proxies_priv OK
[2016-06-01 10:55:44 +0200] mysql.servers OK
[2016-06-01 10:55:44 +0200] mysql.slow_log OK
[2016-06-01 10:55:44 +0200] mysql.tables_priv OK
[2016-06-01 10:55:44 +0200] mysql.time_zone OK
[2016-06-01 10:55:44 +0200] mysql.time_zone_leap_second OK
[2016-06-01 10:55:44 +0200] mysql.time_zone_name OK
[2016-06-01 10:55:44 +0200] mysql.time_zone_transition OK
[2016-06-01 10:55:44 +0200] mysql.time_zone_transition_type OK
[2016-06-01 10:55:44 +0200] mysql.user OK
[2016-06-01 10:55:44 +0200] Running 'mysql_fix_privilege_tables'...
[2016-06-01 10:55:44 +0200] Running 'mysqlcheck with default connection arguments
[2016-06-01 10:55:44 +0200] Running 'mysqlcheck with default connection arguments
SNIP:long output of MySQL repair:SNIP
[2016-06-01 10:55:44 +0200] OK
[2016-06-01 10:55:46 +0200] The 'mysql' service passed the check.
[2016-06-01 10:55:46 +0200] The 'mysql' service passed the check.
[2016-06-01 10:55:52 +0200] Starting MySQL SUCCESS!
[2016-06-01 10:55:52 +0200] Checking MySQL server status after update
[2016-06-01 10:55:52 +0200] The 'mysql' service passed the check.
[2016-06-01 10:55:52 +0200] SUCCESS! MySQL running (30359)
[2016-06-01 10:55:52 +0200] MySQL56-shared-5.6.30-1.cp1156
[2016-06-01 10:55:52 +0200] Hooks system enabled.
[2016-06-01 10:55:52 +0200] Checking for and running RPM::Versions 'post' hooks for any RPMs about to be installed
[2016-06-01 10:55:52 +0200] All required 'post' hooks have been run
[2016-06-01 10:55:52 +0200] Restoring service monitoring.
After this you will be left at the commandline again, let’s check if the server is running the new MySQL version:
mysql --version
mysql Ver 14.14 Distrib 5.6.30, for Linux (x86_64) using EditLine wrapper
That’s it!
As said at the beginning of this post, don’t forget to run EasyApache if you want PHP to work with the upgraded version of MySQL!
There is an easier way of doing this with the cPanel api:
# Upgrading to MariaDB 10.0
whmapi1 start_background_mysql_upgrade version=10.0
More information, could be found here:
https://documentation.cpanel.net/display/DD/WHM+API+1+Functions+-+start_background_mysql_upgrade
Regards
I am searching on google how to upgrade mysql on cpanel and I find your post. And after reading your content, hopefully, now we can update. Thank you!
Now I am wondering, did you succeed using my instructions?