
MariaDB is a popular open-source relational database management system that is a fork of MySQL. It is widely used for its reliability, performance, and open-source nature. This guide will walk you through the steps to install MariaDB on an Ubuntu system.
Prerequisites
Before proceeding with the installation, ensure the following:
- You have access to an Ubuntu server or desktop with 
sudoprivileges. - Your system is updated. Run the following command to update all packages:
 
   sudo apt update && sudo apt upgrade -y
Step 1: Install MariaDB
MariaDB is included in the default Ubuntu repositories, making installation straightforward. Follow these steps:
- Install the MariaDB Server and Client:
Run the following command to install MariaDB: 
   sudo apt install mariadb-server mariadb-client -y
- Verify the Installation:
After the installation is complete, you can verify it by checking the MariaDB version: 
   mariadb --version
This will output the installed version number of MariaDB.
Step 2: Secure the MariaDB Installation
MariaDB includes a security script to help you secure your installation by setting a root password, removing test databases, and disabling anonymous users.
- Run the following command:
 
   sudo mysql_secure_installation
- You will be prompted to configure several options:
 
- Set the root password (if not already set).
 - Remove anonymous users.
 - Disallow remote root login.
 - Remove the test database.
 - Reload privilege tables. Respond to each prompt as needed to secure your installation.
 
Step 3: Start and Enable MariaDB Service
Ensure that the MariaDB service is running and set to start on boot.
- Start the MariaDB service:
 
   sudo systemctl start mariadb
- Enable the service to start on boot:
 
   sudo systemctl enable mariadb
- Check the service status:
 
   sudo systemctl status mariadb
The output should show that the service is active and running.
Step 4: Test MariaDB
To confirm that MariaDB is working as expected, log in to the MariaDB shell.
- Log in using the following command:
 
   sudo mysql
- If successful, you’ll see the MariaDB prompt. Run basic SQL commands to verify functionality, such as:
 
   SHOW DATABASES;
- Exit the MariaDB shell by typing:
 
   EXIT;
Optional: Configure Remote Access
If you need to allow remote access to the MariaDB server, follow these steps:
- Open the MariaDB configuration file:
 
   sudo nano /etc/mysql/mariadb.conf.d/50-server.cnf
- Locate the line that starts with 
bind-addressand change it from127.0.0.1to0.0.0.0: 
   bind-address = 0.0.0.0
- Save and close the file, then restart MariaDB:
 
   sudo systemctl restart mariadb
- Update the firewall rules to allow traffic on the MariaDB port (3306 by default):
 
   sudo ufw allow 3306
Conclusion
You have successfully installed and configured MariaDB on your Ubuntu system. Whether you’re using it for personal projects or production environments, MariaDB provides a robust and efficient solution for managing your databases. If you plan on using it in production, consider additional hardening steps to enhance security.
				


