How to install MariaDB on Ubuntu 20.04

This article was first published in: https://www.itcoder.tech/posts/how-to-install-mariadb-on-ubuntu-20-04/

MariaDB is an open source relational database management system, which is backward compatible and can replace MySQL.

MariaDB was jointly developed by some of the original developers of MySQL and many community members.

This guide will explain how to install and secure MariaDB on Ubuntu 20.04.

1. Prerequisites##

We assume that you have administrative rights to the Ubuntu server, or log in to the system as root or as a user with sudo rights.

2. Install MariaDB on Ubuntu

At the time of writing, the latest version of MariaDB in the Ubuntu software source repository is 10.3. To install it, run the following command:

sudo apt update
sudo apt install mariadb-server

Once the installation is complete, the MariaDB service will start automatically. To verify that the database server is running, enter:

sudo systemctl status mariadb

The output will show that the service is enabled and running:

...

Three, protect MariaDB

MariaDB server has a script called mysql_secure_installation, which allows you to easily improve database server security.

Run the script without parameters:

sudo mysql_secure_installation

The script will prompt you to enter the root password:

Enter current password forroot(enter for none):

Because you have not set a root password, just type "Enter".

In the next prompt, you will be asked whether to set a password for the MySQL root user:

Set root password?[Y/n] n

Enter n. On Ubuntu, MariaDB users use auth_socket for authentication by default. This plugin will check whether the local system user who started the client matches the specified MariaDB username.

In the next step, you will be asked to remove anonymous users, restrict root user access to the local machine, remove the test database, and reload the permissions table. For all questions, you should answer Y:

Remove anonymous users?[Y/n] Y
Disallow root login remotely?[Y/n] Y
Remove test database and access to it?[Y/n] Y
Reload privilege tables now?[Y/n] Y

Fourth, log in as root##

To interact with MariaDB server on the terminal command line, use the mysql client tool or mariadb. This tool is installed as a dependency of the MariaDB server package.

This auth_socket plugin will authenticate users through Unix socket file to connect to localhost. This means that you cannot verify root by providing a password.

To log in to the MariaDB server as the root user, enter:

sudo mysql

You will be shown the MariaDB shell, like the following:

Welcome to the MariaDB monitor.  Commands end with; or \g.
Your MariaDB connection id is 61
Server version:10.3.22-MariaDB-1ubuntu1 Ubuntu 20.04Copyright(c)2000,2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h'for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> Bye

If you want to use a third-party program, such as phpMyAdmin, to log in to your MariaDB server as root, you have two options.

The first is to modify the authentication method from auth_socket to mysql_native_password. You can do it by running the following command:

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'very_strong_password';
FLUSH PRIVILEGES;

The second, the recommended way is to create an administrator user who can access all databases:

GRANT ALL PRIVILEGES ON *.* TO 'administrator'@'localhost' IDENTIFIED BY 'very_strong_password';

You can name this admin user any name you want, but make sure you use a strong password.

Five, summary##

We have shown you how to install MariaDB on Ubuntu 20.04. Your database server is now online and running. Next, you can go to learn How to manage MariaDB user account and data.

If you have any questions, please contact us in the following ways:

WeChat: sn0wdr1am86

WeChat group: add the above WeChat, remark the WeChat group

QQ: 3217680847

QQ Group: 82695646

Recommended Posts

How to install MariaDB on Ubuntu 20.04
How to install Ruby on Ubuntu 20.04
How to install Memcached on Ubuntu 20.04
How to install Java on Ubuntu 20.04
How to install MySQL on Ubuntu 20.04
How to install Elasticsearch on Ubuntu 20.04
How to install Protobuf 3 on Ubuntu
How to install Nginx on Ubuntu 20.04
How to install Node.js on Ubuntu 16.04
How to install MySQL on Ubuntu 20.04
How to install Bacula-Web on Ubuntu 14.04
How to install PostgreSQL on Ubuntu 16.04
How to install Git on Ubuntu 20.04
How to install Anaconda3 on Ubuntu 18.04
How to install Jenkins on Ubuntu 16.04
How to install MemSQL on Ubuntu 14.04
How to install Go on Ubuntu 20.04
How to install MongoDB on Ubuntu 16.04
How to install PrestaShop on Ubuntu 16.04
How to install Python 3.8 on Ubuntu 18.04
How to install KVM on Ubuntu 18.04
How to install KVM on Ubuntu 20.04
How to install opencv3.0.0 on ubuntu14.04
How to install Anaconda on Ubuntu 20.04
How to install Prometheus on Ubuntu 16.04
How to install Jenkins on Ubuntu 18.04
How to install Apache on Ubuntu 20.04
How to install R on Ubuntu 20.04
How to install Moodle on Ubuntu 16.04
How to install Solr 5.2.1 on Ubuntu 14.04
How to install Teamviewer on Ubuntu 16.04
How to install Nginx on Ubuntu 20.04
How to install Mono on Ubuntu 20.04
How to install Go on Ubuntu 20.04
How to install Zoom on Ubuntu 20.04
How to install MariaDB on CentOS 8
How to install Nginx on Ubuntu 16.04
How to install OpenCV on Ubuntu 20.04
How to install Spotify on Ubuntu 20.04
How to install Postman on Ubuntu 18.04
How to install Go 1.6 on Ubuntu 16.04
How to install Go on Ubuntu 18.04
How to install MySQL on Ubuntu 14.04
How to install PostgreSQL on Ubuntu 20.04
How to install VLC on Ubuntu 18.04
How to install TeamViewer on Ubuntu 20.04
How to install Webmin on Ubuntu 20.04
How to install Bacula Server on Ubuntu 14.04
How to install Ubuntu 19.10 on Raspberry Pi 4
How to install Apache Kafka on Ubuntu 18.04
How to install Apache Maven on Ubuntu 20.04
How to install Apache Tomcat 8 on Ubuntu 16.04
How to install Python2 on Ubuntu20.04 ubuntu/focal64
How to install GCC compiler on Ubuntu 18.04
How to install Graylog 1.x on Ubuntu 14.04.
How to install Zabbix on Ubuntu 16.04 Server
How to install Opera web browser on Ubuntu 18.04
How to install Prometheus with Docker on Ubuntu 14.04
How to install Visual Studio Code on Ubuntu 20.04
How to install Squid proxy server on Ubuntu 18.04
How to install Pycharm and Ipython on Ubuntu 16.04/18.04