On this article we will learn about how to install the last stable version of MariaDB on Ubuntu 20.04 LTS operating system.
MariaDB can be used as an alternative to MySQL after the acquisition of MySQL by Sun Microsystems and later by Oracle. MariaDB developers are former developers of MySQL. MariaDB is a community-developed, commercially supported of the MySQL relational database management system (RDBMS), intended to remain free and open-source software under the GNU General Public License. On this article we will learn how to install MariaDB 10.5.8, the latest stable version which was released on 11 November 2020.
MariaDB Installation on Ubuntu 20.04 LTS
We will use MariaDB repository to install the software on the system. For this purpose we have to add MariaDB repository on to the system. The installation steps will consist of several stages, namely:
- Add MariaDB Repository
- MariaDB installation
- Verifty The installation
- Testing MariaDB
We have an updated Ubuntu 20.04 LTS operating system running well with sufficient storage for holding MariaDB files. And then we have
root or an ordinary user account with
sudo privilege. Before installation process, we will update our Ubuntu system to the latest packages by submitting command line :
sudo apt update.
ramansah@otodb02:~$ sudo apt update Get:1 http://security.ubuntu.com/ubuntu focal-security InRelease [109 kB] Hit:2 http://us.archive.ubuntu.com/ubuntu focal InRelease Get:3 http://security.ubuntu.com/ubuntu focal-security/main amd64 DEP-11 Metadata [24.3 kB] Get:4 http://security.ubuntu.com/ubuntu focal-security/main amd64 c-n-f Metadata [7,060 B] Get:5 http://security.ubuntu.com/ubuntu focal-security/universe amd64 Packages [541 kB]
2. Add MariaDB Repository
We will add the newest MariaDB repository to the system by submitting command line :
ramansah@otodb02:~$ curl -LsS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | sudo bash [info] Repository file successfully written to /etc/apt/sources.list.d/mariadb.list [info] Adding trusted package signing keys… [info] Running apt-get update… [info] Done adding trusted package signing keys
3. Install MariaDB
On this stage, we will install MariaDB 10.5.8, by executing command line :
sudo apt-get install mariadb-server galera-4 mariadb-client libmariadb3 mariadb-backup mariadb-common.
ramansah@otodb02:~$ sudo apt-get install mariadb-server galera-4 mariadb-client libmariadb3 mariadb-backup mariadb-common Reading package lists… Done Building dependency tree Reading state information… Done The following additional packages will be installed: gawk libaio1 libcgi-fast-perl libcgi-pm-perl libdbd-mariadb-perl libdbi-perl libfcgi-perl libhtml-template-perl libreadline5 libsigsegv2 libterm-readkey-perl mariadb-client-10.5 mariadb-client-core-10.5 mariadb-server-10.5 mariadb-server-core-10.5 socat Suggested packages: gawk-doc libclone-perl libmldbm-perl libnet-daemon-perl libsql-statement-perl libipc-sharedcache-perl mailx mariadb-test The following NEW packages will be installed: galera-4 gawk libaio1 libcgi-fast-perl libcgi-pm-perl libdbd-mariadb-perl libdbi-perl libfcgi-perl libhtml-template-perl libmariadb3 libreadline5 libsigsegv2 libterm-readkey-perl mariadb-backup 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, 22 newly installed, 0 to remove and 437 not upgraded. Need to get 431 kB/35.0 MB of archives. After this operation, 252 MB of additional disk space will be used. Do you want to continue? [Y/n] Y
4. Verify MariaDB installation And Securing MariaDB
On this step, we will verify the MariaDB installation and securing MariaDB. We will query the MariaDB version and its service by submitting command line :
mariadb --version and
sudo systemctl status mariadb.
ramansah@otodb02:~$ mariadb --version
mariadb Ver 15.1 Distrib 10.5.8-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2
ramansah@otodb02:~$ sudo systemctl status mariadb ● mariadb.service - MariaDB 10.5.8 database server Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled) Drop-In: /etc/systemd/system/mariadb.service.d └─migrated-from-my.cnf-settings.conf Active: active (running) since Fri 2021-02-19 19:46:07 PST; 7min ago Docs: man:mariadbd(8) https://mariadb.com/kb/en/library/systemd/ Main PID: 8799 (mariadbd) Status: "Taking your SQL requests now…" Tasks: 11 (limit: 9451) Memory: 71.3M CGroup: /system.slice/mariadb.service └─8799 /usr/sbin/mariadbd Feb 19 19:46:08 otodb02 /etc/mysql/debian-start: Processing databases Feb 19 19:46:08 otodb02 /etc/mysql/debian-start: information_schema Feb 19 19:46:08 otodb02 /etc/mysql/debian-start: mysql Feb 19 19:46:08 otodb02 /etc/mysql/debian-start: performance_schema Feb 19 19:46:08 otodb02 /etc/mysql/debian-start: Phase 6/7: Checking and upgrading tables Feb 19 19:46:08 otodb02 /etc/mysql/debian-start: Processing databases Feb 19 19:46:08 otodb02 /etc/mysql/debian-start: information_schema Feb 19 19:46:08 otodb02 /etc/mysql/debian-start: performance_schema Feb 19 19:46:08 otodb02 /etc/mysql/debian-start: Phase 7/7: Running 'FLUSH PRIVILEGES' Feb 19 19:46:08 otodb02 /etc/mysql/debian-start: OK
Securing MariaDB, by submitting comman line :
ramansah@otodb02:~$ sudo mysql_secure_installation [sudo] password for ramansah: 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] Y Enabled successfully! Reloading privilege tables.. … Success! 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!
5. Testing MariaDB
On this step, we will test our installed MariaDB by logging in to the database and do query. Log in to MariaDB by submitting command line from the console :
mysql -u root -p.
ramansah@otodb02:~$ mysql -u root -p Enter password: Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 53 Server version: 10.5.8-MariaDB-1:10.5.8+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)]> SELECT VERSION(); +-------------------------------------+ | VERSION() | +-------------------------------------+ | 10.5.8-MariaDB-1:10.5.8+maria~focal | +-------------------------------------+ 1 row in set (0.000 sec) MariaDB [(none)]> MariaDB [(none)]> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | +--------------------+ 3 rows in set (0.001 sec)
We have MariaDB version 10.5.8 installed on the system. We could create new users and database for our applications.
This is a simple steps for installation MariaDB version 10.5.8 (the latest stable version while this article is written). For any information or resources can be found on MariaDB official web site. Have a nice day and thanks for reading.