Introduction
MariaDB is an open source relational database management system derived from MySQL, which has gained popularity in Linux environments thanks to its performance, scalability and compatibility. In this article we will show you step by step how to install, configure and optimize MariaDB in the most used Linux distributions, ensuring that your database is ready for production environments.
Why choose MariaDB in Linux
Choosing MariaDB on a Linux server offers several advantages. It is fully compatible with MySQL, which allows migrating applications without significant changes. Its InnoDB engine and the improvements in complex consultations provide a higher performance in mixed workloads. The active community and frequent updates guarantee long-term security and support. In addition, your GPL license eliminates licensing costs, which makes it ideal for startups and companies seeking to reduce operating costs.
Previous requirements
Before you start, make sure you have root or sweat access on your Linux machine, a stable internet connection and at least 2 GB of free RAM. Check that your distribution is updated by running the corresponding update commands (apt update & & upgrade for Debian / Ubuntu, dnf update for Fedora, yum update for CentOS / RHEL). Having a text editor as nano or vim will facilitate editing of the configuration files.
Installation in Ubuntu and Debian
At Ubuntu and Debian, the installation process is simple thanks to official repositories. Open a terminal and run:sudo apt update; sudo apt install mariadb-server
During installation, you will be asked to set a password for the MariaDB root user. Once finished, the service starts automatically. You can check their status with:sudo systemctl status mariadb
If the service is not active, encourage it and enable it to start at each system start:sudo systemctl start mariadb; sudo systemctl enable mariadb
Installation in CentOS and RHEL
In CentOS and RHEL, MariaDB is located in the standard repositories. First, install the package:sudo yum install mariadb-server mariadb
Then start and enable the service:sudo systemctl start mariadb; sudo systemctl enable mariadb
To improve security, run the security script included:sudo mysql_secure_installation
This script will guide you to set a root password, remove anonymous users, disable remote access for root and remove the test database.
Installation in Fedora
In Fedora, the package manager is dnf. The installation is done as follows:sudo dnf install mariadb-server
Then start and enable the service:sudo systemctl start mariadb; sudo systemctl enable mariadb
As in other distributions, it is recommended to runmysql_secure_installationto tune the security settings.
Basic configuration
After installation, it is recommended to adjust the main configuration file, generally located in/etc/mysql/mariadb.conf.d/50-server.cnf(in Debian / Ubuntu) or/etc/my.cnf.d/mariadb-server.cnf(in RHEL / CentOS / Fedora). Some useful parameters to start with are:
- bind-address = 0.0.0.0 # allows connections from any IP (fits according to your need)
- port = 3306
- max _ connections = 150
- Innodb _ buffer _ pool _ size = 1G # fits according to available RAM
After modifying the file, restart the service:sudo systemctl restart mariadb
Performance optimization
To make the most of MariaDB in Linux, consider these optimizations:
- Increases Innodb _ buffer _ pool _ size to 60-70% of total RAM if the server is dedicated to the database.
- Enable cache query query _ cache _ type only if your workload is of predominant reading and you have enough memory.
- Configure Innodb _ log _ file _ size at an appropriate value (e.g. 256M) to reduce frequent control points.
- Use partitioned tables for large data volumes and improve consultation times.
- It monitors performance with tools such as mysqltuner or Percona Monitoring and Management (PMM).
Essential security
The safety of MariaDB should not be underestimated. Apply these good practices:
- Run mysql _ secure _ installation after installation.
- Restrict access to port 3306 by firewall or ufw, allowing only reliable IP.
- Use encrypted SSL / TLS connections to avoid interceptions.
- regularly update the mariadb-server package to receive security patches.
- Audits the privileges of users and eliminates unnecessary accounts.
- Enable error registration and slow consultation to detect anomalies.
Security and restoration copies
Regular backup is critical. The easiest way is to use mysqldump:
- Security copy of a specific database:
mysqldump -u root -p nombre_base > respaldo_nombre_base.sql
- Security copy of all databases:
mysqldump -u root -p --all-databases > respaldo_completo.sql
To restore, just run:
mysql -u root -p nombre_base < respaldo_nombre_base.sql
Consider automating these tasks with cron and storing backups in a remote site or in cloud storage services.
Conclusion
MariaDB has been consolidated as a robust and free option for managing databases in Linux environments. Its simple installation, MySQL support and extensive set of optimization and security tools make it suitable for both developers and system administrators. Following the steps described in this article, you can have a MariaDB server ready for production, with good performance and the security measures needed to protect your information.


