9 C
Texas

How To Install MariaDB on Ubuntu 20.04

Today we are going to learn that how to Install MariaDB on Ubuntu 20.04 (Focal Fossa). As you all know that Ubuntu 20.04 LTS is now available officially so we brings some topics to help you easily install them on your new upgraded system. Follow the below steps for an easy installation of MariaDB on Ubuntu 20.04.

Step 1: Update Your System

As usual we do, first of all update your system.

sudo apt update && sudo apt upgrade

Also install the software properties common package by the below command

- Advertisement -
sudo apt -y install software-properties-common

Step 2: Importing MariaDB GPG Key

Fire the below command in your terminal to import the MariaDB GPG key into your Ubuntu 20.04 system.

sudo apt-key adv --fetch-keys 'https://mariadb.org/mariadb_release_signing_key.asc'

Step 3: Add the MariaDB Repository on Ubuntu 20.04

Now add the MariaDB repository on Ubuntu 20.04 by the below command.

sudo add-apt-repository 'deb [arch=amd64] http://mariadb.mirror.globo.tech/repo/10.5/ubuntu focal main'

Output:

You’ll see the similar output.

sudo add-apt-repository 'deb [arch=amd64] http://mariadb.mirror.globo.tech/repo/10.5/ubuntu focal main'
Hit:1 http://pk.archive.ubuntu.com/ubuntu focal InRelease
Hit:2 http://pk.archive.ubuntu.com/ubuntu focal-updates InRelease
Hit:3 http://pk.archive.ubuntu.com/ubuntu focal-backports InRelease
Hit:4 http://security.ubuntu.com/ubuntu focal-security InRelease
Get:5 http://mariadb.mirror.globo.tech/repo/10.5/ubuntu focal InRelease [3,202 B]
Get:6 http://mariadb.mirror.globo.tech/repo/10.5/ubuntu focal/main amd64 Packages [7,924 B]
Fetched 11.1 kB in 10s (1,163 B/s)
Reading package lists… Done

Step 4: Install MariaDB Server on Ubuntu 20.04

Once you finished doing the above steps, go for the last step that is to finalize the installation process of MariaDB Server on Ubuntu 20.04. Type the given command in terminal.

sudo apt update
sudo apt install mariadb-server mariadb-client

Then press Y when prompted.

Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
galera-4 gawk libaio1 libdbd-mariadb-perl libdbi-perl
libhtml-template-perl libmariadb3 libreadline5 libterm-readkey-perl
mariadb-client-10.5 mariadb-client-core-10.5 mariadb-common
mariadb-server-10.5 mariadb-server-core-10.5 socat
Suggested packages:
gawk-doc libmldbm-perl libnet-daemon-perl libsql-statement-perl
libipc-sharedcache-perl mailx mariadb-test tinyca
The following NEW packages will be installed:
galera-4 gawk libaio1 libdbd-mariadb-perl libdbi-perl
libhtml-template-perl libmariadb3 libreadline5 libterm-readkey-perl
mariadb-client mariadb-client-10.5 mariadb-client-core-10.5
mariadb-common mariadb-server mariadb-server-10.5
mariadb-server-core-10.5 socat
0 upgraded, 17 newly installed, 0 to remove and 1 not upgraded.
Need to get 28.2 MB of archives.
After this operation, 222 MB of additional disk space will be used.
Do you want to continue? [Y/n]

Step 5: Securing MariaDB on Ubuntu 20.04

As there are by default settings so for security reasons we’ve to update the settings so that we are not open to vulnerabilities. To do this secure the MariaDB installation on Ubuntu 20.04 with the help of below command.

sudo mysql_secure_installation

You’ll see the similar output.

sabi@Ubuntu-20:~$ sudo mysql_secure_installation
[sudo] password for sabi:
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
haven't set the root password yet, you should just press enter here.
Enter current password for root (enter for none):
OK, successfully used password, moving on…
Setting the root password or using the unix_socket ensures that nobody
can log into the MariaDB root user without the proper authorisation.
You already have your root account protected, so you can safely answer 'n'.
Switch to unix_socket authentication [Y/n] N
… skipping.
You already have your root account protected, so you can safely answer 'n'.
Change the root password? [Y/n] Y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
… Success!
By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.
Remove anonymous users? [Y/n] y
… Success!
Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] y
… Success!
By default, MariaDB comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.
Remove test database and access to it? [Y/n] y
Dropping test database…
… Success!
Removing privileges on test database…
… Success!
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] y
… Success!
Cleaning up…
All done! If you've completed all of the above steps, your MariaDB
installation should now be secure.
Thanks for using MariaDB!

Make sure to check the MariaDB Server status as it will start automatically after completing the installation. Run the below command to see the status of MariaDB on Ubuntu 20.04.

systemctl status mysql
How To Install MariaDB on Ubuntu 20.04

After it test the login by providing the above details configured in the above step.

sabi@Ubuntu-20:~$ mysql -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 51
Server version: 10.5.2-MariaDB-1:10.5.2+maria~focal mariadb.org binary distribution
Copyright (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)]>

So, this is how you can install MariaDB on your Ubuntu 20.04. If you’ve any queries, feel free to ask. To show your support towards us simply do share our posts and always look for new and interesting content from us.

- Advertisement -
Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

LEAVE A REPLY

Please enter your comment!
Please enter your name here



Latest article