In this blog post, we’ll look at how to replace MySQL with Percona Server for MySQL on a CPanel, WHM VPS or dedicated server.
In general, CPanel and WHM have been leaning towards support of MariaDB over other flavors. This is partly due to the upstream repos replacing the MySQL package with MariaDB (for example, on CentOS).
MySQL 5.6 is still supported though, which means they are keeping support for core MySQL products. But if you want to get some extra performance enhancements or enterprise features for free, without getting too many bells and whistles, you might want to install Percona Server.
I’ve done this work on a new dedicated server with the latest WHM and CPanel on CentOS 7, with MySQL 5.6 installed. Besides the backup, this is a fairly quick process.
It’s pretty simple. From the Percona Server for MySQL 5.7 installation doc, we can get the YUM repo. (Run commands as root if you can, otherwise as sudo.)
1 | yum install http://www.percona.com/downloads/percona-release/redhat/0.1-3/percona-release-0.1-3.noarch.rpm |
Now that we have the repo, let’s install Percona XtraBackup in case we need to roll this back at any point:
1 | yum install percona-xtrabackup |
This server had a drive mounted at /backup, so I created the backup with the following commands:
1 2 | xtrabackup --target-dir=/backup/xtrabackup --backup xtrabackup --target-dir=/backup/xtrabackup --prepare |
Now that we have a good backup, let’s remove MySQL:
1 2 | service mysql stop yum remove MySQL* mysql* |
Depending on your dependency chain, this could remove Percona XtraBackup, but that can be fixed. Let’s accept this uninstall.
Let’s install Percona Server for MySQL 5.7 and Percona Toolkit:
1 | yum install Percona-Server-server-57 percona-toolkit percona-xtrabackup |
Now that it’s installed ensure the mysql service is running. If it isn’t, start it. Now let’s upgrade:
1 | mysql_upgrade |
NOTE. This works if you can log in as root without a password; if you can’t, you will need to specify the -u and -p flags.
Once you run the upgrade, restart the mysql service:
1 | service mysql restart |
Additional Steps to Make Cpanel and Apache Work Correctly with this Change
You may get errors like this:
1 | file /usr/sbin/mysqld-debug from install of MySQL56-server-5.6.34-2.cp1156.x86_64 conflicts with file from package Percona-Server-server-57-5.7.16-10.1.el7.x86_64 |
Run:
1 2 3 4 5 6 | /usr/local/cpanel/scripts/update_local_rpm_versions --edit target_settings.MySQL50 uninstalled /usr/local/cpanel/scripts/update_local_rpm_versions --edit target_settings.MySQL51 uninstalled /usr/local/cpanel/scripts/update_local_rpm_versions --edit target_settings.MySQL55 uninstalled /usr/local/cpanel/scripts/update_local_rpm_versions --edit target_settings.MySQL56 uninstalled /usr/local/cpanel/scripts/update_local_rpm_versions --edit target_settings.MariaDB100 uninstalled /usr/local/cpanel/scripts/update_local_rpm_versions --edit target_settings.MariaDB101 uninstalled |
This will tell Cpanel that it shouldn’t try to install these. Cpanel suggests running this as well:
1 | ln -sv /usr/lib64/libperconaserverclient.so /usr/lib64/libmysqlclient.so |
Now you need to rebuild EasyApache’s PHP to ensure that all PHP modules remain intact:
1 | /usr/local/cpanel/scripts/easyapache —build |
And there you go, you are now running on Percona Server for MySQL 5.7. If your managed providers tell you it’s not supported, don’t worry! It works as long as CPanel supports MySQL 5.6.
If you have any issues, just restore the backup.
NOTE: One thing to keep in mind is that 5.7 breaks CPanel’s ability to create users in MySQL. I believe this is due to the changes to the mysql.user table. If this is an issue for you, you can always use Percona Server for MySQL 5.6.
This is incomplete. Please see https://documentation.cpanel.net/display/CKB/How+to+Replace+MySQL+with+Percona for the proper steps to install Percona, on a cPanel server.
Andrei, I added more info based on your link. Thank you so much. It solved some issues I saw in the test environment I was working in.
That link was removed, any fresh link?
I have vps with hostgator centOS running mysql 5.6, Shall I install percona server as instructed above and leave mysql as it is? Or shall I replace Mysql server?
would this be the same process if replacing MariaDB, instead of MySQL? …replacing any “yum mysql…” references with “yum maria…” references?
i’m trying replace mariadb on a CentOS7 w/ CloudLinux7 using MySql_Governor… thought I’d ask… couldn’t hurt 😉
i m using Cpanel now. alpharapid.com is my site is now on MySQL 5.7 is it good to install poercona. i m not using cloudlinux
at present mysql take too much load /usr/sbin/mysqld –daemonize –pid-file=/var/run/mysqld/mysqld.pid some tome it take 20-35% load please help to reduce