How to Upgrade MariaDB on Linux (AlmaLinux)

Spread the love
How to Upgrade MariaDB on Linux

How to Upgrade MariaDB on Linux. A well-known open-source relational database is MariaDB. MariaDB was developed by the same programmers who worked on MySQL and made a commitment to keep it open source. Most cloud services include it, and most Linux distributions use it as the default.

It is based on the ideas of performance, stability, and openness. The MariaDB Foundation further promises that contributions will be accepted on the basis of technical merit. You can be sure you’re using the database platform’s top features by regularly updating MariaDB versions.

With each successive MariaDB version, numerous new features and enhancements have been made. You must upgrade MariaDB to the most recent supported versions to get important security upgrades and prevent difficulties with other programs. Maintaining MariaDB’s updates will give you access to new features, greater security, and improved performance, among other advantages.

Conditions Before MariaDB Upgrades

  • Operating System & Version: For this tutorial, the OS must be AlmaLinux OS 8.
  • Repository & Version: a version of MariaDB besides the most recent.
  • Administrative rights on Linux: Use the sudo command as root or as a user with administrative rights to log into the AlmaLinux 8 system.

AlmaLinux MariaDB upgrade

Step 1: Verify the versions of MariaDB and AlmaLinux

The following commands can be used to determine MariaDB and AlmaLinux’s current versions:

  • ~]# mysql -V
  • ~]# cat /etc/redhat-release

This is the result:

[root@nouf ~]# mysql -V mysql Ver 15.1 Distrib 10.5.21-MariaDB, for Linux (x86_64) using readline 5.1 [root@nouf ~]# cat /etc/redhat-release AlmaLinux release 8.8 (Sapphire Caracal)

Step 2: Next, create a database backup.

A backup or dump of the current databases and database configuration file must be made prior to initiating a MariaDB update.

Make use of the following command to dump the database:

  • ~]# mysqldump –all-databases > /tmp/all-database-backup.sql

Use the following command to move the database directory into a different folder:

  • ~]# cp -a /var/lib/mysql /var/lib/mysql_oldbackup

Use the next command to backup the configuration file:

  • ~]# cp -a /etc/my.cnf /etc/my.cnf_oldbackup

Keep in mind that if the file is present, you should also back up the contents of /etc/my.cnf.d.

Step 3: Disconnect the existing MariaDB repository

Remove the older MariaDB repositories before installing the most recent version. The MariaDB service can be stopped by using the command shown below:

  • ~]# systemctl stop mariadb

Use the following command to verify MariaDB’s present status:

  • ~]# systemctl status mariadb

Use the following command to rename or relocate the currently selected repository file:

  • ~]# mv /etc/yum.repos.d/mariadb.repo /etc/yum.repos.d/mariadb.repo_oldbackup

Step 4: Include a New MariaDB Repository (or “Repo”)

All the packages need to be updated before you can create a new MariaDB repository. To update all the packages, run the following command:

  • ~]# sudo dnf update -y

For the most recent MariaDB version, you can now make a new repository file:

  • ~]# vi /etc/yum.repos.d/mariadb.repo

Then, include the following information in the file /etc/yum.repos.d/mariadb.repo and save it:

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

Step 5: Remove the previous MariaDB version

With the help of the following command, you can remove the previous version of MariaDB:

  • ~]# sudo dnf remove MariaDB-server -y

Use the following command to clear your server’s repository cache:

  • ~]# sudo dnf clean all

Step 6: Install the most recent version of MariaDB.

You are now prepared to update MariaDB. Utilize the following command to install the most recent version of MariaDB:

  • ~]# sudo dnf install MariaDB-server -y

This is the result:

[root@nouf ~]# sudo dnf install MariaDB-server -y AlmaLinux 8 – BaseOS 6.0 MB/s | 4.0 MB 00:00 AlmaLinux 8 – AppStream 16 MB/s | 11 MB 00:00 AlmaLinux 8 – Extras 32 kB/s | 18 kB 00:00 MariaDB 1.0 MB/s | 620 kB 00:00 Dependencies resolved. ========================================================================================================================================================================= Package Architecture Version Repository Size ========================================================================================================================================================================= Installing: MariaDB-server x86_64 10.10.5-1.el8 mariadb 27 M —- —- Installed: MariaDB-server-10.10.5-1.el8.x86_64 boost-program-options-1.66.0-13.el8.x86_64 galera-4-26.4.14-1.el8.x86_64 libpmem-1.6.1-1.el8.x86_64 lsof-4.93.2-1.el8.x86_64 socat-1.7.4.1-1.el8.x86_64 Complete!

Use the following command to install the most popular MariaDB packages as part of the overall MariaDB upgrade:

  • ~]# sudo dnf install galera-4 MariaDB-client MariaDB-shared MariaDB-backup MariaDB-common -y

Step 7: Launch MariaDB

Using the following command, the MariaDB service can be started:

  • ~]# sudo systemctl start mariadb

Step 8: Configure MariaDB to Launch Upon Boot

Use the following command to instruct MariaDB to launch when the system boots:

  • ~]# sudo systemctl enable mariadb

This is the result:

[root@nouf ~]# sudo systemctl enable mariadb Created symlink /etc/systemd/system/multi-user.target.wants/mariadb.service → /usr/lib/systemd/system/mariadb.service.

Step 9: Update MariaDB

Make advantage of the following command to upgrade MariaDB:

  • ~]# mysql_upgrade

This is the result:

[root@nouf ~]# mysql_upgrade Major version upgrade detected from 10.5.21-MariaDB to 10.10.5-MariaDB. Check required! Phase 1/7: Checking and upgrading mysql database Processing databases mysql mysql.column_stats OK mysql.columns_priv OK mysql.db OK mysql.event OK mysql.func OK mysql.gtid_slave_pos OK mysql.help_category OK mysql.help_keyword OK mysql.help_relation OK mysql.help_topic OK mysql.host OK mysql.index_stats OK mysql.innodb_index_stats OK mysql.innodb_table_stats OK mysql.plugin OK mysql.proc OK mysql.procs_priv OK mysql.proxies_priv OK mysql.roles_mapping OK mysql.servers OK mysql.table_stats OK mysql.tables_priv OK mysql.time_zone OK mysql.time_zone_leap_second OK mysql.time_zone_name OK mysql.time_zone_transition OK mysql.time_zone_transition_type OK mysql.transaction_registry OK mysql.user OK Phase 2/7: Installing used storage engines… Skipped Phase 3/7: Fixing views Phase 4/7: Running ‘mysql_fix_privilege_tables’ Phase 5/7: Fixing table and database names Phase 6/7: Checking and upgrading tables Processing databases information_schema performance_schema Phase 7/7: Running ‘FLUSH PRIVILEGES’ OK

Step 10: Check the Most Recent MariaDB Version.

To check and confirm the MariaDB version that is presently installed, use the command line:

  • ~]# mysql -V

This is the result:

[root@nouf ~]# mysql -V mysql Ver 15.1 Distrib 10.10.5-MariaDB, for Linux (x86_64) using readline 5.1 [root@nouf ~]#

Congratulations on finishing the MariaDB upgrade successfully!

MariaDB database security

On AlmaLinux 8, the most recent version of MariaDB has been installed. The MariaDB Database can now be secured by using the command:

  • ~]# sudo mysql_secure_installation

This is the result:

[root@nouf ~]# sudo 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. Set 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] Y … Success! 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 … Success! 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] Y – Dropping test database… … Success! – Removing privileges on test database… … Success! Reloading the privilege tables will ensure that all changes made so far will take effect immediately. Reload privilege tables now? [Y/n] Y … Success! Cleaning up… All done! If you’ve completed all of the above steps, your MariaDB installation should now be secure. Thanks for using MariaDB!

Learn more about the key distinctions between MySQL and MariaDB in our knowledge base and blog online resources if you wish to switch from MySQL to MariaDB. Once you have installed MariaDB, you will occasionally need to upgrade MariaDB in order to make use of the newest features.

Conclusion

Now that you know how to upgrade MariaDB on AlmaLinux, you can proceed. Additionally addressed were the steps for creating a backup, removing the old version, and securing MariaDB following an upgrade. A great MySQL substitute is MariaDB, which hosts databases.

Also Read: When Should Your Server Be Upgraded?

Also Read: An Arch Linux installation guide for Linux lovers

Also Read: How to Setup Jenkins on Linux Alma

Leave a Reply

Your email address will not be published. Required fields are marked *