MariaDB is a free, open-source database management system that replaces the proprietary MySQL database management system. Many new features and changes have been added and improved in each MariaDB version. For version 10.8.0, some new features include:
- Lag free ALTER TABLE in replication.
- Descending indexes.
- Auto create partition.
For those looking to take advantage of new features, this tutorial walks you through how to upgrade MariaDB on CentOS 7.
- A server running in Centos 7.
- A version of MariaDB running that is not the latest version.
- Root access to the server.
Upgrade MariaDB in CentOS 7
Step 1: Check the MariaDB and CentOS Versions
Check the current MariaDB version and CentOS version using the below commands.
mysql -V cat /etc/centos-release
Step2: Backup the Database
When performing an upgrade, creating a backup or a dump of the existing databases is important. Dump the database with the following command.
mysqldump --all-databases > /tmp/database-backup.sql
Alternatively, copy the database directory into a separate folder using this command.
cp -a /var/lib/mysql /var/lib/mysql.backup
Backup the configuration file with this command.
cp -a /etc/my.cnf /etc/my.cnf_bk
In case of any failures in the upgrade, you can use one of the above copies to restore your databases.
Step 3: Uninstall the Current MariaDB Repository.
You will need to uninstall the old MariaDB repositories before installing the newer version. To do so, you must first stop the MariaDB service using the below command.
systemctl stop mariadb
Check the current status of MariaDB using this command.
systemctl status mariadb
Move the current repo file using the below command.
mv /etc/yum.repos.d/mariadb.repo /etc/yum.repos.d/mariadb_bk
Step 4: Add the New MariaDB Repository
All the packages need to be up-to-date. Use the following command to update your packages.
Create a new repo file for the latest version.
Copy and paste the following contents into the /etc/yum.repos.d/mariadb.repo file.
[mariadb] name = MariaDB baseurl = http://yum.mariadb.org/10.6/centos7-amd64 gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB gpgcheck=1
To exit and save the Vim file, type :wq and press Enter.
Step 5: Uninstall the Old MariaDB Version
Uninstall the old version of MariaDB using the below command. This command completely removes the old MariaDB version and leaves the databases.
yum remove mariadb-server
Clean the repository cache on your server with this command.
yum clean all
Step 6: Install the Latest Version of MariaDB on Centos 7
Install the new version of MariaDB using the command below.
yum install MariaDB-server
To install the latest version of MariaDB and the most common packages, run the following command.
yum install MariaDB-server galera-4 MariaDB-client MariaDB-shared MariaDB-backup MariaDB-common
Step 7: Start MariaDB
Start the MariaDB service with this command.
systemctl start mariadb
Step 8: Set MariaDB to Start at Boot
To set MariaDB to start automatically when the server boots up, use the following command.
systemctl enable mariadb
Step 9:Upgrade MariaDB on CentOS 7
Run the upgrade command to upgrade MariaDB.
Step 10: Check the Current MariaDB Version
Check the currently installed MariaDB version with this command.
MariaDB has been successfully upgraded to the latest version.
Step 11: Secure the MariaDB Database Server
Now that the latest MariaDB version has been installed on CentOS 7, secure it by running the following command.
Follow the script prompts to choose which actions to carry out.
# mysql_secure_installation NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY! In order to log into MariaDB to secure it, we'll need the current password for the root user. If you've just installed MariaDB, and you haven't set the root password yet, the password will be blank, so you should just press enter here. Enter current password for root (enter for none): OK, successfully used password, moving on... Setting the root password ensures that nobody can log into the MariaDB root user without the proper authorisation. You already have a root password set, so you can safely answer 'n'. Change the root password? [Y/n] y New password: Re-enter new password: Password updated successfully! Reloading privilege tables.. ... Success! By default, a MariaDB installation has an anonymous user, allowing anyone to log into MariaDB without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment. Remove anonymous users? [Y/n] n ... skipping. Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network. Disallow root login remotely? [Y/n] y ... skipping. By default, MariaDB comes with a database named 'test' that anyone can access. This is also intended only for testing, and should be removed before moving into a production environment. Remove test database and access to it? [Y/n] n ... skipping. Reloading the privilege tables will ensure that all changes made so far will take effect immediately. Reload privilege tables now? [Y/n] n ... skipping. Cleaning up... All done! If you've completed all of the above steps, your MariaDB installation should now be secure. Thanks for using MariaDB!
This tutorial will guide you on how to upgrade MariaDB in CentOS 7. It includes tips for taking a backup, uninstalling the old version, and securing MariaDB once upgraded. For database hosting, MariaDB is an excellent substitute for MySQL.
Our Sales and Support teams are available 24 hours by phone or e-mail to assist.