MariaDB is a powerful open-source database system, designed as a drop-in replacement for MySQL. It’s known for stability, scalability, and security. Running MariaDB on a Linux server ensures optimal performance for web applications, e-commerce platforms, and enterprise databases, while allowing developers to easily create MariaDB on Linux for managing and scaling their data.

In this article, we are going to cover how to create MariaDB on a Linux Server, including installation, configuration, and best practices to help you set up a secure and efficient database environment.
Prerequisites
Before installing MariaDB, your server must meet some requirements. Preparing these in advance prevents installation errors and saves time.
- A Linux distribution (Ubuntu, Debian, CentOS, or RHEL)
- Root or sudo user access
- Stable internet connection
- Basic command-line knowledge
Step-by-Step Guide to Install MariaDB on Linux
Installing MariaDB on Linux is simple, but following the correct sequence ensures a smooth setup. Here are the steps for Ubuntu, Debian, CentOS, and RHEL distributions.
Updating the System
Keeping your system packages updated prevents version conflicts and security issues.
sudo apt update && sudo apt upgrade -y # Ubuntu/Debian
sudo yum update -y # CentOS/RHEL
- Installing MariaDB Server
Use the package manager of your Linux distribution to install MariaDB.
On Ubuntu/Debian:
sudo apt install mariadb-server -y
- On CentOS/RHEL:
sudo yum install mariadb-server -y
- Starting and Enabling MariaDB Service
After installation, you need to start MariaDB and make sure it runs at boot.
sudo systemctl start mariadb
sudo systemctl enable mariadb
- Verifying Installation
Confirm that MariaDB is running successfully with the following commands:
sudo systemctl status mariadb
mysql -u root -p
Configuring MariaDB on Linux
Once installed, MariaDB needs to be configured to enhance security and performance. Proper configuration helps protect your database and prepare it for real-world usage.
- Securing MariaDB Installation
Run the built-in security script to set up essential protections.
sudo mysql_secure_installation
This allows you to:
- Set a strong root password
- Remove anonymous users
- Disable remote root login
- Remove test databases
- Creating Databases and Users
You can now create databases and assign users with the necessary privileges.
CREATE DATABASE mydb;
CREATE USER 'myuser'@'localhost' IDENTIFIED BY 'mypassword';
GRANT ALL PRIVILEGES ON mydb.* TO 'myuser'@'localhost';
FLUSH PRIVILEGES;
Securing MariaDB on Linux Server
Securing MariaDB protects your data against unauthorized access and attacks. Implementing best practices strengthens the database environment and minimizes risks.
- Firewall Rules: Restrict port 3306 to trusted IPs.
- Enable SSL/TLS: Secure client-server communication.
- Restrict Remote Access: Limit external connections.
- Regular Updates: Keep MariaDB packages updated.
Managing MariaDB Services on Linux
After setup, managing MariaDB services ensures smooth performance and quick troubleshooting. Knowing how to control these services is crucial for system administrators.
- Starting and Stopping MariaDB
Use these commands to stop MariaDB for maintenance or restart it when needed.
sudo systemctl stop mariadb
sudo systemctl start mariadb
- Restarting and Reloading MariaDB
Restarting applies major changes, while reloading applies minor changes without downtime.
sudo systemctl restart mariadb
sudo systemctl reload mariadb
- Checking Service Status
Always check MariaDB’s status to confirm it is active and running smoothly.
sudo systemctl status mariadb
- Enabling MariaDB on Boot
Enable MariaDB at startup to ensure it loads automatically after reboots.
sudo systemctl enable mariadb
- Monitoring Logs
Logs provide insights into performance issues and errors. On Ubuntu, check /var/log/mysql/
, while CentOS logs are usually stored in /var/log/mariadb/
.
Common Issues and Fixes
MariaDB can sometimes run into problems, but most are easy to fix with the right commands.
- MariaDB Failed to Start
- Check logs in
/var/log/mariadb/
for errors. - Fix incorrect settings in
my.cnf
.
- Check logs in
- Access Denied for User
- Verify user privileges with:
SHOW GRANTS FOR 'myuser'@'localhost';
- Port 3306 in Use
- Check if another service is using the port:
sudo lsof -i :3306
- Update MariaDB configuration if needed.
For advanced troubleshooting, official resources can help you quickly fix MariaDB issues in Linux.
FAQs to Create MariaDB on Linux Server
How do I check the installed MariaDB version on Linux?
You can check with mysql --version
or by logging into MariaDB using mysql -u root -p
and running SELECT VERSION();
. Both methods confirm the exact version running on your server.
Can I use MariaDB as a replacement for MySQL on Linux?
Yes, MariaDB is fully compatible with MySQL. Most applications and tools that support MySQL also support MariaDB without any modifications, making it a reliable replacement for Linux-based systems.
How do I reset the MariaDB root password in Linux?
Stop the MariaDB service, restart it with --skip-grant-tables
, log in without authentication, update the root password using SQL commands, and restart normally. This allows you to securely regain access to your server.
Conclusion
MariaDB is a secure, reliable, and high-performance database solution for Linux servers. In this guide, we covered installation, configuration, securing databases, managing services, and fixing common issues. With proper setup and management, MariaDB can handle everything from small applications to large enterprise workloads efficiently. For more, visit MariaDB’s Official documentation.