[Tutorial]How to remove MariaDB and replace with MySQL on CyberPanel

Disclaimer: the CyberPanel was designated to work on MariaDB , although MySQL and MariaDB are compatible in almost every aspect , I have personally tested on Centos 7.4 with CyberPanel 1.6 , alone with a demo wordpress site, but this is NOT guaranteed risk-free.

A proper backup is always recommended and needed.

mysql 5.6 was installed in this tutorial , but 5.5 and 5.7 should work , you just have to manually edit version number in mysql repo

alright , there is a little problem , vanilla will convert anything comes with ' within.

for command on step 1 , 12 and 13, please grab them here if you are not clear about them.

here you go:

step1: make backup of entire database

MYSQL_PWD=cat /etc/cyberpanel/mysqlPassword mysqldump -u root --all-databases > /root/backup.sql

step2: stop mariadb

systemctl stop mysqld

step3: remove mariadb repo

rm -rf /etc/yum.repos.d/MariaDB.repo

step4: download mysql repo

wget -O /etc/yum.repos.d/mysql.repo https://cn.cyberpanel.net/download/repo/mysql56.repo

step5: remove yum cache

yum clean all && rm -rf /var/cache/yum

step6: remove mariadb

yum remove MariaDB-server MariaDB-client MariaDB-common -y

step7: re-install all the dependencies that removed during step6 (be aware, this is a very long command , check if it ends with "-y" if not try split it into 2 commands and intall them)

yum install MySQL-python dovecot-mysql lsphp53-mysql lsphp53-snmp lsphp54-mysql 
lsphp54-snmp lsphp55-mysql lsphp55-snmp lsphp56-mysql lsphp56-snmp lsphp70-snmp lsphp71-snmp net-snmp pdns-backend-mysql postfix pure-ftpd -y

step8: install mysql

yum install mysql-community-server -y

step9: reload

systemctl daemon-reload

step10: start mysql

systemctl start mysqld

step11(optional):check if mysqls are running , it should be listening on 3306 and 3307

netstat -lnp|grep 330

step12: import the backed up database from step1

MYSQL_PWD=cat /etc/cyberpanel/mysqlPassword mysql -u root < /root/backup.sql

step13: mysql_upgrade

MYSQL_PWD=cat /etc/cyberpanel/mysqlPassword mysql_upgrade -u root

step14( NOT recommended ): remove backed up files to free some disk space

rm -rf /root/backup.sql


Sign In or Register to comment.
Support CyberPanel CyberPanel Discord

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!