in this guide, we are going to install & configure MariaDB server community edition on Linux server.
MariaDB
MariaDB Community Server is the open source relational database loved by developers all over the world. Created by MySQL’s original developers, MariaDB is compatible with MySQL and guaranteed to stay open source forever. MariaDB powers some of the world’s most popular websites such as Wikipedia and WordPress.com. It is also the core engine behind banking, social media, mobile and e-commerce sites worldwide.
~ MariaDB Website
MariaDB Server is a great RDBMS for running production & Dev/Test OLTP workloads like , CRM, E-Commerce, ERP Systems, in this guide we are installing MariaDB on a Linux server.
In this Guide I have prepared a VM with specs below, Depending on your environment and your application data access pattern replace these resources to meet your application demand.
CPU | Memory | Distro |
---|---|---|
2 Cores | 2 GiB | Debian 10 |
Make sure you have access to your server and have administrative privileges to run sudo command.
Setup & Configuration
First thing is to update package repositories to get the latest version of packages. if your system is already update feel free to skip two next steps
If you just provisioned the server, it would likely be outdated , run a full system upgrade to install security patches.
Next we are installing the MariaDB server and client and mycli utility which is a great utility that provide command and SQL completion and suggestion to simplify database administration tasks.
After the installation is done, we have to run the MySQL secure installation command, it is an interactive script that guides you through some security measures to harden your database server, it resets insecure default configurations and removes default users & databases.
The output :
After running secure installation script you can go and test connection between your client and server, but by default majority of MariaDB server packages or the script we just ran bind the server to localhost or even go further and disable networking. To check if your installation has the same behavior you can run the command below
To configure the server to allow remote connection there, but first let’s backup the configuration file.
To allow access to a static IP you can run this one-liner.
Or if you want the database to be publicly available.
Restart mariadb-server service.
Now you should be able to to see mysql port open for remote connections.
Creating Databases and Users
Create Database for your application
Create application database user
Grant all application database privileges for the application user from a host you can specify:
- ”*” : from anywhere
- “192.168.1.%” : from network subnet
- “mydomain” : for a domain name
- “1.1.1.1” : for a static IP address
To debug user access you can run the following commands
Resources
- Linuxhint Grant Privileges to users MySQL
- MariaDB Documentation
- Configuring MariaDB for Remote Client Access
- MyCLI Project
Conclusion
We saw how to install and configure a MariaDB instance, ext we troubleshooted remote connection, in this guide we covered some basic configuration steps to secure and operate the database, there are some advanced steps that needs to be done like installing TLS certifications and configuring backups. Thank you for reading this guide and stay tuned for more tutorials in future.