How to Install MariaDB 10.4 on Ubuntu 18.04

Introduction

MariaDB is an open source, fully compatible, relational database management system. It is commonly used as a replacement for MySQL due to its fault tolerance, speed, and scalability.

In this tutorial, you will learn how to install the latest version of MariaDB on Ubuntu 18.04.

ubuntu-mariadb-install

Prerequisites

  • A command line/terminal window
  • A user account with sudo privileges
  • The apt package manager, included by default

Installing Latest MariaDB Version on Ubuntu 18.04 from Repositories

When installing MariaDB directly from its official repositories, you have the option to select a version for installation. The guide below focuses on the installation of MariaDB 10.4, the latest version available.

Note: Please visit the MariaDB Foundation downloads page to select the desired version. The instructions may differ slightly based on the chosen version to install.

Step 1: Add MariaDB Repositories

  1. Before attempting to install the software from independent sources like MariaDB, we will add packages that will help manage repositories more efficiently:
sudo apt-get install software-properties-common
  1. Import the MariaDB GPG key by using the following command:
sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8
  1. Add the MariaDB apt repository:
sudo add-apt-repository 'deb [arch=amd64,arm64,ppc64el]http://nyc2.mirrors.digitalocean.com/mariadb/repo/10.4/ubuntu/ bionic main'

Step 2: Install MariaDB

  1. Update the packages list:
sudo apt update
  1. Install the MariaDB package:
sudo apt install mariadb-server mariadb-client -y

The MariaDB service starts automatically.

  1. Verify that the database is active and running, use the command:
sudo systemctl status mariadb

This is an example of the expected output:

verify MariaDB database is running Ubuntu
  1. Check the MariaDB server version:
mysql -V

The terminal displays a detailed description of the version currently installed:

mysql  Ver 15.1 Distrib 10.4.4-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2

Step 3: Secure MariaDB

To define security levels and access privileges, run the following command:

sudo mysql_secure_installation

You now have the option to define the ‘root’ user password as well as create MariaDB user accounts.

Additionally, a series of questions will help you fine-tune your security settings. It is recommended to answer Yes (Y) to all of the questions. These short descriptions will help you to make an informed decision.

  • Set root password? – Allows you to create a root database password.
  • Remove anonymous users? – MariaDB has an anonymous user intended only for testing. Remove the default anonymous user before moving into a production environment. As it can quickly become a security liability.
  • Disallow root login remotely?Restrict ‘root’ user access to the local machine. This prevents the possibility of remote logins.
  • Remove test database and access to it?MariaDB has a default database intended for testing only. Remove it before moving to a production environment, as it is publicly accessible.
  • Reload privilege tables now? – Reload the privilege tables to make sure that all the changes made take effect immediately

How to Connect to MariaDB from the Command Line

To connect to MariaDB from the command line, enter the command:

mysql -u root -p

Use the password defined earlier and the following screen will appear:

welcome to mariadb monitor

Now you will have access to the MariaDB monitor.

To gain control of the terminal again:

exit;

or alternatively use:

/q

Note: If you need a database for storing complex data, that allows you to modify documents without affecting existing data structures. you may want to try installing MongoDB.

Conclusion

By following these steps, you have successfully installed the latest version of MariaDB on Ubuntu 18.04. We have also significantly improved database security levels by editing the default settings.

Most importantly, you have gained valuable insight and practice that will allow you to perform similar tasks more easily in the future.

原创文章,作者:506227337,如若转载,请注明出处:https://blog.ytso.com/224030.html

(0)
上一篇 2022年1月7日
下一篇 2022年1月7日

相关推荐

发表回复

登录后才能评论