Why upgrade?
MySQL is the database program behind many websites. Each version adds fixes, security patches and speed. Old versions stop getting security updates, so they become unsafe over time.
Tip: CentOS is old software now, and the commands here use yum. Newer systems like AlmaLinux and Rocky Linux work in a very similar way.
If you run cPanel/WHM, do not upgrade with the steps below. Use MySQL/MariaDB Upgrade in WHM instead, or ask Hostvento support. Manual changes can break cPanel.
Warning
An upgrade can break websites if their software does not support the new version. Make a full backup first. Test on a copy of the server if you can. Plan some downtime.
Step 1: Back up everything
- Log in over SSH as root. SSH lets you type commands on your server.
- Dump all databases into one file:
mysqldump -u root -p --all-databases > /root/all-databases.sql
This saves a full copy of every database. Copy the file somewhere safe, away from the server.
- Also copy the data folder:
cp -a /var/lib/mysql /root/mysql-data-backup
Stop MySQL first with systemctl stop mysqld so the copy is clean, then start it again.
Step 2: Check your version
mysql --version
It prints the version you have now. MySQL upgrades should go one major version at a time, for example 5.6 to 5.7, then 5.7 to 8.0.
Step 3: Add the new repository
A repository is an online store of software packages. Install the MySQL repository file from the official MySQL website that matches your CentOS version. Then pick the version you want:
yum-config-manager --disable mysql57-community
yum-config-manager --enable mysql80-community
The first line turns off the old version source. The second turns on the new one. Names change per version, so check the repo list with yum repolist all | grep mysql.
Step 4: Upgrade
- Stop MySQL:
systemctl stop mysqld
- Update the packages:
yum update mysql-community-server
- Start MySQL again:
systemctl start mysqld
MySQL 8.0 upgrades its data files by itself on first start. On older versions, run mysql_upgrade -u root -p after starting.
Step 5: Test
- Run
mysql --versionto confirm the new version. - Open your websites and check that they work.
- Watch the error log for problems.
Quick recap
- You need root access, and cPanel servers should use WHM's upgrade tool.
- Back up first with
mysqldumpand a copy of the data folder. - Upgrade one major version at a time.
- Use the new repository and
yum update. - Test every website afterwards.