How To Install MariaDB on Linux Mint 22
In this tutorial, we will show you how to install MariaDB on Linux Mint 22. MariaDB has gained significant traction in the open-source community as a fork of MySQL, offering enhanced performance, additional features, and improved compatibility. Its seamless integration with Linux systems makes it an ideal choice for developers, system administrators, and database enthusiasts alike.
This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo
‘ to the commands to get root privileges. I will show you the step-by-step installation of the MariaDB database on Linux Mint 22.
Prerequisites
- A server running one of the following operating systems: Linux Mint 22.
- It’s recommended that you use a fresh OS install to prevent any potential issues.
- While we’ll guide you through the process, a basic understanding of the command line will be beneficial. If you’re new to the CLI, you might want to acquaint yourself with some fundamental commands.
- CPU: 1 GHz or faster processor (2 GHz or faster recommended).
- RAM: 2 GB minimum (4 GB or more recommended).
- Storage: At least 20 GB of free disk space.
- An active internet connection.
- Administrative privileges are essential for installing and configuring software on your system. Ensure that you have superuser or sudo access.
Install MariaDB on Linux Mint 22
Step 1. Update Your Linux Mint System.
Before installing any new software, it’s essential to ensure your system is up-to-date. This step helps prevent compatibility issues and ensures you have the latest security patches. Open a terminal and run the following command to update the package index:
sudo apt update sudo apt upgrade
This command retrieves the latest package information from the repositories, allowing you to install the most recent versions of MariaDB and its dependencies.
Step 2. Installing MariaDB.
With your system updated, you’re ready to install MariaDB. We’ll add the official MariaDB repository to ensure we get the latest stable version.
First, install the software-properties-common package, which allows you to add PPAs:
sudo apt install software-properties-common
Next, add the MariaDB repository:
sudo add-apt-repository 'deb [arch=amd64,arm64,ppc64el] http://ftp.osuosl.org/pub/mariadb/repo/10.5/ubuntu focal main'
Import the GPG key to verify package integrity:
sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xcbcb082a1bb943db
Update the package index again to include the new repository:
sudo apt update
Now, install MariaDB:
sudo apt install mariadb-server
This command installs the MariaDB server and all necessary dependencies.
Step 3. Secure MariaDB Installation
After installation, it’s crucial to secure your MariaDB server. MariaDB provides a security script that helps you implement best practices for database security.
Execute the following command to start the security script:
sudo mysql_secure_installation
Follow the prompts to configure security settings:
-
- Set a root password if not already set.
- Remove anonymous users.
- Disallow root login remotely.
- Remove the test database and access it.
- Reload privilege tables.
Answer “Y” (yes) to all prompts for maximum security. Here’s a sample interaction:
Enter current password for root (enter for none): [Press Enter] Set root password? [Y/n] Y New password: [Enter a strong password] Re-enter new password: [Repeat the password] Remove anonymous users? [Y/n] Y Disallow root login remotely? [Y/n] Y Remove test database and access to it? [Y/n] Y Reload privilege tables now? [Y/n] Y
These steps significantly enhance the security of your MariaDB installation.
Step 4. Verify MariaDB Installation
After installation and security configuration, it’s important to verify that MariaDB is running correctly.
To check the status of the MariaDB service, run:
sudo systemctl status mariadb
If the service isn’t running, start it with:
sudo systemctl start mariadb
To ensure MariaDB starts automatically on system boot, enable the service:
sudo systemctl enable mariadb
Step 5. Basic MariaDB Configuration.
With MariaDB installed and secured, let’s perform some basic configuration tasks to get you started with database management.
Log in to the MariaDB shell:
sudo mysql -u root -p
From the MariaDB shell, create a new database:
CREATE DATABASE example_db;
Create a new user and grant them privileges on the new database:
CREATE USER 'example_user'@'localhost' IDENTIFIED BY 'password'; GRANT ALL PRIVILEGES ON example_db.* TO 'example_user'@'localhost'; FLUSH PRIVILEGES;
Verify your new database and user:
SHOW DATABASES; USE example_db; SHOW TABLES;
Step 6. Setting Up Firewall Rules.
If you’re using UFW (Uncomplicated Firewall), allow incoming connections on port 3306:
sudo ufw allow 3306/tcp sudo ufw reload
Congratulations! You have successfully installed MariaDB. Thanks for using this tutorial to install the latest version of the MariaDB database on the Linux Mint system. For additional help or useful information, we recommend you check the official MariaDB website.