All Collections
VPS
CyberPanel VPS
How to upgrade/downgrade MySQL (MariaDB) on VPS?
How to upgrade/downgrade MySQL (MariaDB) on VPS?
Upgrading and downgrading MariaDB MySQL package on CyberPanel VPS
Updated over a week ago

There might be the case when you need to upgrade or downgrade the MariaDB MySQL package on your VPS. For example, when the MariaDB version, currently installed on your server, isn't supported by CMS of your website.

In the examples below, we will be downgrading from MariaDB 10.5 to MariaDB 10.4 - you'll be able to perform changes to any version by replacing the version in SSH commands.

Step 1 - Back up your database

First, connect to your server using SSH and check CyberPanel and root MySQL passwords. This can be done by executing:

cat .db_password

Then create a fresh backup:

mysqldump -u root -p --all-databases > databasedump.sql

Use the password in the .db_password file.

Step 2 - Change the MariaDB version

When we have a backup, you can remove the MariaDB version.

Then, add MariaDB YUM repository: vim

/etc/yum.repos.d/MariaDB.repo 

and update the file to:

[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.4/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB gpgcheck=1

After this, update the yum cache index:

yum makecache fast

And install the new version of MariaDB:

yum install MariaDB-server MariaDB-client

Don't forget to enable MariaDB:

systemctl start mariadb

And start it:

systemctl enable mariadb

The final touch - secure MariaDB:

mysql_secure_installation

Use the same password in .db_password. A different version of MariaDB (10.4 in our case) should now be running, you can check with mysql --v:

image

Step 3 - Import your database

Finally, import your database's backup:

mysql -u root -p root < databasedump.sql

And restart MariaDB:

systemctl restart mariadb

That's it, your MariaDB version was successfully updated!

NOTE:

Did this answer your question?