[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

Comments

  • Note: Its a good practice to run auto repair and optimize at the end.

  • @Tishu said:
    Note: Its a good practice to run auto repair and optimize at the end.

    I can't edit my own post now ...

  • edited December 2017

    I think I missed something.

    after all that

    run

    mv -f /etc/my.cnf.rpmsave /etc/my.cnf
    rm -rf /etc/systemd/system/mysql.service
    rm -rf /etc/systemd/system/mysqld.service
    systemctl enable mysqld
    systemctl restart mysqld
    mv -f /etc/postfix/master.cf.rpmsave /etc/postfix/master.cf
    mv -f /etc/postfix/main.cf.rpmsave /etc/postfix/main.cf
    systemctl enable postfix
    systemctl restart postfix
    mv -f /etc/pure-ftpd/pureftpd-mysql.conf.rpmsave /etc/pure-ftpd/pureftpd-mysql.conf
    mv -f /etc/pure-ftpd/pure-ftpd.conf.rpmsave /etc/pure-ftpd/pure-ftpd.conf
    systemctl enable pure-ftpd
    systemctl restart pure-ftpd
    
  • Please do NOT use this guide , it left some serious problem I am still working on it...

Sign In or Register to comment.
CyberPanel Discord

Howdy, Stranger!

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