How to install MariaDB Server in cPanel/WHM servers

[Total: 3    Average: 5/5]

MariaDB is an enhanced drop-in replacement for MySQL. Latest stable version of MariaDB is 10.0. First of all, we need to take the backup of all the databases in the server and then we can safely proceed with the MariaDB installation.

Features of MariaDB

* Data and table definition files (.frm) files are binary compatible.
* All client APIs, protocols and structs are identical.
* All filenames, binaries, paths, ports, sockets, and etc… should be the same.
* All MySQL connectors (PHP, Perl, Python, Java, .NET, MyODBC, Ruby, MySQL C connector etc) work unchanged with MariaDB.
* The mysql-client package also works with MariaDB server.
* The shared client library is binary compatible with MySQL’s client library.

Step 1: Backup existing MySQL databases. Refer below the URL
https://www.24x7serversolutions.com/blog/how-to-take-mysql-databases-backup-with-command-line/

step 2 :Make copy of existing MySQL config file in case something goes wrong

 cp -ar /etc/my.cnf /etc/my.cnf-old

Step 3: Stop and disable the MySQL service

/etc/init.d/mysql stop

WHM >> Service Manager >> Uncheck MySQL >> Save

Step 4: Disable the targets so cPanel no longer handles MySQL updates

/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

Step 5: Uninstall MySQL

/scripts/check_cpanel_rpms --fix --targets=MySQL50,MySQL51,MySQL55

Step 6: Install MariaDB

Create file /etc/yum.repo.d/mariadb.repo and add below lines if your server is CentOS 6 64bit.

# MariaDB 5.5 CentOS repository list - created 2014-01-05 00:39 UTC
# http://mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/5.5/centos6-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1

Step 7: Now install the MariaDB

yum install MariaDB-server MariaDB-client MariaDB-devel

For different OS get the repo lines from https://downloads.mariadb.org/mariadb/repositories/

Step 8: Restart and update MariaDB

# /etc/init.d/mysql start
# mysql_upgrade
# /etc/init.d/mysql restart

Final Step: Rebuild Easyapache/PHP to ensure modules are intact/working

# /scripts/easyapache --build

That’s it !!!!