Use MariaDB on a Linux server to manage your databases efficiently with an open-source, high-performance relational database system. MariaDB is a popular alternative to MySQL, offering enhanced features and wide compatibility with Linux distributions.

In this article, you’ll learn how to use MariaDB on a Linux server—from installation and securing your database to basic management tasks.
Prerequisites
- Supported Linux distributions: Ubuntu, Debian, CentOS, Red Hat, Oracle Linux
- Root or sudo access to install and manage services
- Access to the command line terminal
Use MariaDB on a Linux Server
MariaDB is a powerful, open-source relational database management system that is a drop-in replacement for MySQL. Running MariaDB on a Linux server provides high performance, scalability, and security for managing structured data in web applications, enterprise software, and more. It supports advanced features such as Galera Cluster, data replication, and robust storage engines, making it a preferred choice for developers and system administrators looking for a reliable database solution.
Install MariaDB on a Linux Server
To use MariaDB on a Linux server, install it via your distribution’s package manager for an easy setup.
- Ubuntu/Debian:
sudo apt update
sudo apt install mariadb-server mariadb-client
- CentOS/Red Hat:
sudo yum update
sudo yum install mariadb-server mariadb
Optionally, you can add the official MariaDB repository for the latest version by running:
curl -LsS https://r.mariadb.com/downloads/mariadb_repo_setup | sudo bash
sudo apt update
sudo apt install mariadb-server mariadb-client
This will ensure you install the most current stable release.
Start and Enable MariaDB Service
Make sure the MariaDB service is running and starts automatically on boot.
- Start the service:
sudo systemctl start mariadb
- Enable MariaDB to launch on system boot:
sudo systemctl enable mariadb
- Check the service status:
sudo systemctl status mariadb
Active status means MariaDB is running properly.
Secure Your MariaDB Installation
Running the security script helps you protect your MariaDB installation by setting a root password and removing default insecure settings.
sudo mysql_secure_installation
You will be prompted to:
- Set a root password
- Remove anonymous users
- Disable remote root login
- Remove the test database
- Reload privilege tables
Answer accordingly (usually “Y” for yes) to strengthen your server security.
Test MariaDB Installation
Verify your installation and log in to the MariaDB server.
- Check MariaDB version:
mariadb --version
- Connect to MariaDB as root:
sudo mariadb -u root -p
Enter the root password you set during the secure installation. You will enter the MariaDB shell, where you can run SQL commands.
Check Out | Beginner’s Guide to Understanding MariaDB on Linux Easily
Basic MariaDB Server Management
With MariaDB running, you can create and manage databases and users.
- Create a new database:
CREATE DATABASE mydatabase;
- Create a new user and assign a password:
CREATE USER 'myuser'@'localhost' IDENTIFIED BY 'strong_password';
- Grant all privileges on the database to the new user:
GRANT ALL PRIVILEGES ON mydatabase.* TO 'myuser'@'localhost';
FLUSH PRIVILEGES;
- List all databases:
SHOW DATABASES;
- Exit the MariaDB shell:
EXIT;
For troubleshooting, view MariaDB logs:
- Ubuntu/Debian:
/var/log/mysql/error.log
- CentOS/Red Hat:
/var/log/mariadb/mariadb.log
or
/var/log/mysqld.log
Additional Tips for Beginners
Once you have MariaDB installed and running, there are several best practices and tools you can adopt to improve your workflow, security, and monitoring as a beginner:
Use GUI Tools for Easy Management
Working with databases via the command line can be tricky at first. Tools like:
- phpMyAdmin (web-based, simple interface)
- DBeaver (multi-platform, powerful features)
- HeidiSQL (great for managing queries and users)
These interfaces make database tasks like editing tables or running SQL queries more intuitive.
Keep MariaDB Updated
Regular updates improve security and performance. Run:
sudo apt update && sudo apt upgrade mariadb-server
Or use your system’s package manager. Always back up before updating.
Set Up Monitoring and Alerts
Use tools like:
- Zabbix or Nagios for uptime and performance monitoring
- Prometheus + Grafana for real-time insights and dashboards
Monitoring helps you detect slow queries, connection issues, or server overload early.
Conclusion
To use MariaDB on a Linux server, install the MariaDB packages, start and enable the service, then secure your installation by setting up passwords and removing insecure defaults. You are then ready to manage databases and users with MariaDB’s powerful tools seamlessly integrated into your Linux environment. Using MariaDB provides a reliable database platform suitable for everything from personal projects to enterprise applications. For more information, visit MariaDB’s Official documentation.