How to replace MySQL with MariaDB in 11.36

MariaDB is an enhanced, drop-in replacement for MySQL – best of all, nobody from Oracle phones you trying to sell you a premium version!
I see many applications moving over to soon when Oracle steps up it’s marketing, after all, I assume that is why Oracle bought MySQL.

Here’s how I replaced MySQL with MariaDB on cPanel/WHM.
As it is a drop in replacement, no data is lost and everything works as before including phpMyAdmin.

Backup your existing MySQL data

[codesyntax lang=”bash”]
cp -Rf /var/lib/mysql /var/lib/mysql-backup
mv /etc/my.cnf /etc/my.cnf-backup

 

Tell WHM/cPanel not to update MySQL anymore. You will be responsible for manually updating MariaDB via yum.

[codesyntax lang=”bash”]
/scripts/update_local_rpm_versions –edit target_settings.MySQL50 uninstalled
/scripts/update_local_rpm_versions –edit target_settings.MySQL51 uninstalled
/scripts/update_local_rpm_versions –edit target_settings.MySQL55 uninstalled

Depending on your WHM/cPanel version, you may need to both of the following steps

 

i.  Create a mysqlupdisable file in /etc

[codesyntax lang=”bash”]
touch /etc/mysqlupdisable

 

ii. Edit  /etc/cpupdate.conf and add the following

[codesyntax lang=”bash”]
MYSQLUP=never

Remove the currently installed MySQL

[codesyntax lang=”bash”]
/scripts/check_cpanel_rpms –fix –targets=MySQL50,MySQL51,MySQL55

 

 

Look out for any errors. You should see  Shutting down MySQL…….. SUCCESS!

Install the MariaDB repos

[codesyntax lang=”bash”]
/etc/yum.repos.d/MariaDB.repo

 

Add
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/5.5/centos5-x86
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
Save and exit.

Install MariaDB

[codesyntax lang=”bash”]
yum install MariaDB-server MariaDB-client MariaDB-devel php-mysql
/etc/init.d/mysql start

Convert and upgrade the existing databases

[codesyntax lang=”bash”]
mysql_upgrade
/etc/init.d/mysql restart

 

Finally, rebuild apache. This can be done one of two ways;

i. Use easyapache

[codesyntax lang=”bash”]
/scripts/easyapache –build

 

ii. That may not work, I had to rebuild PHP seperately.

[codesyntax lang=”bash”]
cd /home/cpeasyapache/src/

 

Change into the latest PHP directory.

Grab your PHP configure options;

[codesyntax lang=”bash”]
php -i|grep configure

 

You should see something like
Configure Command => ‘./configure’ ‘–enable-bcmath’ ‘–enable-calendar’ ‘–enable-exif’ ‘–enable-ftp’ ‘–enable-gd-native-ttf’ ‘–enable-libxml’ ‘–enable-magic-quotes’ ‘–enable-mbstring’ ‘–enable-pdo=shared’ ‘–enable-sockets’ ‘–enable-zip’ ‘–prefix=/usr/local’ ‘–with-apxs2=/usr/local/apache/bin/apxs’ ‘–with-bz2’ ‘–with-curl=/opt/curlssl/’ ‘–with-curlwrappers’ ‘–with-freetype-dir=/usr’ ‘–with-gd’ ‘–with-imap=/opt/php_with_imap_client/’ ‘–with-imap-ssl=/usr’ ‘–with-jpeg-dir=/usr’ ‘–with-kerberos’ ‘–with-libdir=lib64’ ‘–with-libexpat-dir=/usr’ ‘–with-libxml-dir=/opt/xml2/’ ‘–with-mcrypt=/opt/libmcrypt/’ ‘–with-mysql=/usr’ ‘–with-mysql-sock=/var/lib/mysql/mysql.sock’ ‘–with-mysqli=/usr/bin/mysql_config’ ‘–with-openssl=/usr’ ‘–with-openssl-dir=/usr’ ‘–with-pcre-regex=/opt/pcre’ ‘–with-pdo-mysql=shared’ ‘–with-pdo-sqlite=shared’ ‘–with-pic’ ‘–with-png-dir=/usr’ ‘–with-sqlite=shared’ ‘–with-xmlrpc’ ‘–with-xpm-dir=/usr’ ‘–with-zlib’ ‘–with-zlib-dir=/usr’
You may need to remove the apostrophes and then run that command.
If that completes successfully, run;

[codesyntax lang=”bash”]
make && make install

If that completes successfully, run;

[codesyntax lang=”bash”]
service httpd restart

Author: Kieran Barnes

Kieran is a PHP developer with 15 years commercial experience. Specialist in WordPress, CakePHP, CubeCart and all things PHP.

1 thought on “How to replace MySQL with MariaDB in 11.36”

Leave a Reply

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