Install MariaDB on Linux
Learn how to install mariadb service on different linux distributions
This documentation has been extracted from mariadb oficial page
This guide will walk you through the steps to install MariaDB 11.4.3 on a Linux system based on Debian (such as Ubuntu, Debian itself, or other derivatives). MariaDB is an open-source relational database system that is a popular choice for many web applications.
Prerequisites
A running Debian-based system (e.g., Ubuntu 22.04, Debian 11).
Root or sudo access.
A stable internet connection for package downloads.
Step-by-Step Installation Guide
1. Update Your System
First, make sure your package lists are up to date.
2. Install Prerequisites
MariaDB requires some dependencies to be installed on your system, like software-properties-common
to manage repositories.
3. Add the MariaDB 11.4 Repository
To install the latest version of MariaDB (11.4.3), you need to add the official MariaDB repository to your system.
Import the MariaDB GPG key:
Add the MariaDB repository:
If you're using a different Debian-based distribution, replace
bullseye
with your version codename (e.g.,focal
for Ubuntu 20.04).
4. Update Package Lists Again
After adding the MariaDB repository, update your package list to include the new packages from MariaDB:
5. Install MariaDB 11.4.3
Now you can install MariaDB 11.4.3 using the following command:
6. Start and Enable MariaDB Service
After installation, start the MariaDB service and enable it to automatically start on system boot:
7. Secure the MariaDB Installation
MariaDB includes a security script to remove default settings that are insecure. Run this script:
You will be prompted to:
Set a root password (if not set during installation).
Remove anonymous users.
Disallow remote root login.
Remove the test database.
Reload privilege tables.
Answer "Y" to all prompts for a secure installation.
8. Verify Installation
To verify that MariaDB is correctly installed and running, use:
You should see the service status as "active" (running).
Additionally, log into the MariaDB shell:
Enter the root password you created earlier, and you'll be logged into the MariaDB shell. To confirm the version, run:
You should see something like:
9. Basic Configuration (Optional)
You can configure MariaDB by editing the my.cnf
configuration file:
Make any changes you need, then restart the service:
Common Commands
Start MariaDB:
Stop MariaDB:
Restart MariaDB:
Check MariaDB Status:
Last updated