How To Install MariaDB on Ubuntu 20.04
MariaDB is a community-developed, commercially supported fork of the MySQL relational database management system, intended to remain free and open-source software under the GNU General Public License.
Installing MariaDB
To install it, update the package index on your server with apt:
apt update
Output:
root@vps:~# apt update
Hit:1 http://deb.debian.org/debian bullseye InRelease
Get:2 http://deb.debian.org/debian bullseye-updates InRelease [39.4 kB]
Get:3 http://security.debian.org/debian-security bullseye-security InRelease [44.1 kB]
Get:4 http://deb.debian.org/debian bullseye-updates/main Sources.diff/Index [4,995 B]
Get:5 http://deb.debian.org/debian bullseye-updates/main amd64 Packages.diff/Index [4,995 B]
Get:6 http://deb.debian.org/debian bullseye-updates/main Sources T-2022-01-24-2024.03-F-2022-01-24-2024.03.pdiff [238 B]
Install mariadb server.
apt install mariadb-server
Output:
root@vps:~# apt install mariadb-server
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
galera-4 gawk libaio1 libcgi-fast-perl libcgi-pm-perl libclone-perl libconfig-inifiles-perl libdbd-mariadb-perl libdbi-perl
libencode-locale-perl libfcgi-bin libfcgi-perl libfcgi0ldbl libhtml-parser-perl libhtml-tagset-perl libhtml-template-perl libhttp-date-perl
libhttp-message-perl libio-html-perl liblwp-mediatypes-perl libmariadb3 libmpfr6 libsigsegv2 libsnappy1v5 libterm-readkey-perl
libtimedate-perl liburi-perl mariadb-client-10.5 mariadb-client-core-10.5 mariadb-common mariadb-server-10.5 mariadb-server-core-10.5
mysql-common psmisc rsync socat
Configuring MariaDB
mysql_secure_installation
Adjusting User Authentication and Privileges
mysql -u root -p
Create a new user with root privileges and password-based access.
GRANT ALL ON *.* to 'admin'@'localhost' IDENTIFIED BY 'password' WITH GRANT OPTION;
Output:
MariaDB [(none)]> GRANT ALL ON *.* to 'admin'@'localhost' IDENTIFIED BY
'password' WITH GRANT OPTION;
Query OK, 0 rows affected (0.001 sec)
Flush the privileges to ensure that they are saved and available in the current session:
FLUSH PRIVILEGES;
Exit the MariaDB shell:
exit;
Testing MariaDB
systemctl status mariadb
Output:
root@vps:~# systemctl status mariadb
● mariadb.service - MariaDB 10.5.12 database server
Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vend>
Active: active (running) since Thu 2022-03-03 15:20:55 UTC; 3min 2>
Docs: man:mariadbd(8)
https://mariadb.com/kb/en/library/systemd/
Process: 10429 ExecStartPre=/usr/bin/install -m 755 -o mysql -g roo>
Process: 10433 ExecStartPre=/bin/sh -c systemctl unset-environment >
Process: 10438 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recov>
Process: 10511 ExecStartPost=/bin/sh -c systemctl unset-environment>
Process: 10513 ExecStartPost=/etc/mysql/debian-start (code=exited, >
Main PID: 10499 (mariadbd)
Status: "Taking your SQL requests now..."
Tasks: 10 (limit: 1133)
Memory: 82.6M
If you configured a separate administrative user with password authentication, you could perform the same operation by typing:
sudo mysqladmin version
Output:
root@vps:~# sudo mysqladmin version
mysqladmin Ver 9.1 Distrib 10.5.12-MariaDB, for debian-linux-gnu on x86_64
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Server version 10.5.12-MariaDB-0+deb11u1
Protocol version 10
Connection Localhost via UNIX socket
UNIX socket /run/mysqld/mysqld.sock
Uptime: 4 min 1 sec
Once Configured, you can connect to MariaDB and review the existing databases on your database server by using the following command.
mysql -e "SHOW DATABASES;" -p
Output:
root@vps:~# mysql -e "SHOW DATABASES;" -p
Enter password:
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
+--------------------+
root@vps:~#
Done.
CrownCloud - Get a SSD powered KVM VPS at $4.5/month!
Use the code WELCOME
for 10% off!
1 GB RAM / 25 GB SSD / 1 CPU Core / 1 TB Bandwidth per month
Available Locations: LAX | MIA | ATL | FRA | AMS