Linux Tactic

MariaDB on Ubuntu 1804: Secure Installation Guide for Beginners

Installing and

Securing MariaDB on Ubuntu 18.04: A Beginner’s Guide

If you’re running a website or any other online service, chances are you’re already familiar with MySQL, one of the most widely used relational databases in the world. MariaDB is a fork of MySQL that was created by its original developers after concerns rose about its acquisition by Oracle Corporation back in 2010.

Since then, MariaDB has become an increasingly popular choice for users who want a feature-rich, open-source, and community-driven alternative to MySQL. In this article, we will guide you through the process of installing and securing MariaDB on Ubuntu 18.04, one of the most popular Linux distributions available.

Our goal is to provide a comprehensive yet simple overview of the steps you need to take to get up and running with MariaDB, along with some best practices to keep your database secure.

Installing MariaDB from Ubuntu Repositories

One of the easiest ways to get MariaDB up and running on Ubuntu is to install it from Ubuntu’s official repositories. Here’s how:

1.

Open a terminal window and enter the following command to update the package list:

“`

sudo apt-get update

“`

2. Enter the following command to install MariaDB:

“`

sudo apt-get install mariadb-server

“`

3. The installation process will prompt you to enter a root password for MariaDB.

Choose a strong, unique password (ideally, a mix of uppercase and lowercase letters, numbers, and special characters), and remember to keep it safe. 4.

Once the installation is complete, start the MariaDB service by entering the following command:

“`

sudo systemctl start mariadb

“`

You can check the status of the service by running:

“`

sudo systemctl status mariadb

“`

If everything went smoothly, you should see a message that says “active (running)” indicating that MariaDB is up and running.

Installing MariaDB from Official Repositories

If you prefer to install MariaDB from its official repositories, here’s how:

1. Add MariaDB’s GPG key to Ubuntu’s keyring:

“`

sudo apt-get install software-properties-common

sudo apt-key adv –fetch-keys ‘https://mariadb.org/mariadb_release_signing_key.asc’

“`

2. Add the MariaDB repository to Ubuntu’s repository list:

“`

sudo add-apt-repository ‘deb [arch=amd64,arm64,ppc64el] http://mirror.nforce.com/MariaDB/repo/10.6/ubuntu bionic main’

“`

Note that there are different versions of MariaDB available for different Ubuntu releases.

Make sure you choose the one that corresponds to your system. 3.

Update the package list:

“`

sudo apt-get update

“`

4. Install MariaDB by running:

“`

sudo apt-get install mariadb-server

“`

5. Follow the same steps as above to set up a root password and start the service.

Securing MariaDB

After installing MariaDB, it’s crucial to take some basic steps to secure your database. Here are some best practices to follow:

1.

Run the following command to secure MariaDB using mysql_secure_installation:

“`

sudo mysql_secure_installation

“`

The script will prompt you to set a new root password, remove anonymous users, disallow root login remotely, remove test databases, and reload privilege tables. 2.

Choose a strong password policy that requires users to choose complex passwords and reset them periodically. 3.

Use SSL/TLS encryption to secure the connection between clients and the database. 4.

Limit network access to only those hosts and subnets that need to connect to the database. 5.

Regularly update and patch MariaDB to ensure that you’re running the latest security fixes.

Connecting to MariaDB from the Command Line

Once MariaDB is set up and secured, you can connect to it from the command line using the mysql client. Here’s how:

1.

Open a terminal window and enter the following command to launch the mysql client:

“`

mysql -u root -p

“`

2. Enter your root password when prompted.

3. You should now be in the MariaDB shell, where you can execute SQL commands to manage your databases and tables.

For example, you can create a new database by running:

“`

CREATE DATABASE mydb;

“`

4. To view a list of all databases, run:

“`

SHOW DATABASES;

“`

5.

To select a specific database to work with, run:

“`

USE mydb;

“`

Conclusion

We hope this article has provided you with a good understanding of how to install and secure MariaDB on Ubuntu 18.04. By following these steps, you can rest assured that your database is up and running, secured, and ready to use.

Remember to regularly check for updates and apply security patches to ensure that your MariaDB installation is always up to date and protected from potential attacks. In this article, we’ve discussed how to install and secure MariaDB on Ubuntu 18.04.

We’ve provided step-by-step instructions on how to install MariaDB from Ubuntu and official repositories, along with best practices for securing the database. We’ve also covered how to connect to MariaDB from the command line.

It’s important to secure your database by choosing a strong password, enabling SSL/TLS encryption, and limiting network access to only necessary hosts. MariaDB is a feature-rich, open-source, and community-driven alternative to MySQL that is gaining popularity among users.

Remember to regularly update and patch your installation to ensure the security of your database.

Popular Posts