How to Upgrade MariaDB in Ubuntu 18.04 LTS

The MariaDB server is a popular, open-source relational database known in the standard repositories of all major Linux distributors.
One of the leading causes to upgrade MariaDB is errors such as the following.
json not null
This error is displayed because an older version of MariaDB does not natively support JSON data types.
This article discusses how to take a backup and upgrade MariaDB in Ubuntu 18.04 LTS.
What is MariaDB?
MariaDB Community Server is a free and open source fork of the MySQL database software. Its uses include data warehousing, eCommerce, and logging applications.
MariaDB works in any dedicated or cloud infrastructure, on a small or large scale. The most popular application of MariaDB is for content management systems (CMS). A CMS uses the MariaDB database without needing to program it. Instead, it works directly in the website source code.
Requirements
- A server running Ubuntu 18.04 LTS.
- A version of MariaDB running that is not the latest.
- Root access to the server.
Upgrade MariaDB in Ubuntu 18.04 LTS
A MariaDB upgrade in Ubuntu requires uninstalling the old version and installing the new version. The best practice is to take a backup before changing the existing server if issues arise.
These issues may corrupt the database files, preventing you from quickly reverting to the older version. A backup allows restoration if needed and can be deleted once the upgrade is successful.
Step 1: Backup MariaDB
Use the following syntax to take a full backup. Confirm the backup completed by checking the directory for the file.
$ sudo mariabackup --backup \
--user=mariabackup_user \
--password=mariabackup_passwd \
--target-dir=/data/backup/preupgrade_backup
Use the following command to prepare the backup.
$ sudo mariabackup --prepare \
--target-dir=/data/backup/preupgrade_backup
Step 2: Stop MariaDB
Stop MariaDB from running using the following command.
$ sudo systemctl stop mariadb
Step 3: Uninstall the Old Version of MariaDB
The upgrade process requires uninstalling the old version before installing the new version of MariaDB. Use the following command to uninstall the previous version.
$ sudo apt-get remove mariadb-server
Step 4: Install the Latest Version of MariaDB on Ubuntu
Install the latest version of MariaDB via the APT package manager (Debian/Ubuntu).
1. Configure the APT package repository. This step involves adding a key for the MariaDB server repo and then updating.
$ sudo apt install wget
$ wget https://downloads.mariadb.com/MariaDB/mariadb_repo_setup
$ echo "fd3f41eefff54ce144c932100f9e0f9b1d181e0edd86a6f6b8f2a0212100c32c mariadb_repo_setup" \
| sha256sum -c -
$ chmod +x mariadb_repo_setup
$ sudo ./mariadb_repo_setup \
--mariadb-server-version="mariadb-10.5"
$ sudo apt update
2. Install MariaDB and package dependencies. Installing additional packages may require additional plugins.
$ sudo apt install mariadb-server mariadb-backup
Step 5: Configure MariaDB
1. MariaDB requires configuration before the database server is ready for use. Ubuntu 18.04 LTS uses systemd. Below are the systemctl commands used to manage the MariaDB server processes.
Operation | Commands |
Start | sudo systemctl start mariadb |
Stop | sudo systemctl stop mariadb |
Restart | sudo systemctl restart mariadb |
Enable During Startup | sudo systemctl enable mariadb |
Disable During Startup | sudo systemctl disable mariadb |
Status | sudo systemctl status mariadb |
2. Once you start the server processes, run the below utility to upgrade the data directory. MariaDB comes with the mariadb-upgrade utility, which identifies and corrects the compatibility issues in the latest version.
$ sudo mariadb-upgrade
3. You can now start MariaDB with the following command.
$ sudo systemctl start mariadb
4. After upgrading the data directory and ensuring MariaDB is up and running in your system, ensure no issues arise during startup by verifying the MariaDB version.
Connect to the server using the MariaDB client with the root user account. You can also verify the version of the server in the client's initial output.
$ sudo mariadb
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 9
Server version: 10.5.13-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]>
Additional configuration changes are available through the option files.
Wrap Up
This tutorial discusses how to upgrade MariaDB in Ubuntu 18.04 LTS and the reasons for upgrading. MariaDB is a great alternative and drop-in replacement to MySQL for database hosting.
Liquid Web offers 27/7/365 support to help customers upgrade MariaDB in Ubuntu and other Linux operating systems. Our VPS and dedicated hosting options are a great way to test compatibility and switch to MariaDB. Contact our sales team today to get started.
Related Articles:
- How to Force HTTPS For Your Domain
- 2 Methods of Checking Apache Version
- How to Install Adminer MySQL Database Management Tool on AlmaLinux
- How to Edit the PHP Memory for Your WordPress Site via WP Toolkit
- 4 Methods for How to Install Yarn on Windows Server
- How to Install Bpytop Resource Monitoring Tool on AlmaLinux
About the Author: Ayshath Mansoora
Ayshath is a skilled DevOps engineer with three years of experience in Linux administration, web hosting, and DNS management. Check out her LinkedIn profile for additional information about her.
Our Sales and Support teams are available 24 hours by phone or e-mail to assist.
Latest Articles
How to Force HTTPS For Your Domain
Read ArticleWhat is CGI-Bin and What Does it Do?
Read ArticleTop 10 Password Security Standards
Read ArticleTop 10 Password Security Standards
Read ArticleHow to Use the WP Toolkit to Secure and Update WordPress
Read Article