Skip to Content

Installing MariaDB 11 on Ubuntu

How to install MariaDB 11 on Ubuntu?


Overview: This article provides step-by-step instructions for installing MariaDB 11 on an Ubuntu server.


Step 1:  Update the system

root@gateway:~# apt update && sudo apt -y upgrade

Step 2: Add MariaDB APT repository

root@gateway:~# curl -LsS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | sudo bash -s -- --mariadb-server-version=11.2

# [info] Checking for script prerequisites.
# [info] MariaDB Server version 11.2 is valid
# [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

Step 3: Now install MariaDB server and client packages from configured repositories.

root@gateway:~# apt update

root@gateway:~# apt -y install mariadb-server mariadb-client

Step 4: After installing all dependencies, confirm the version of current MariaDB.

root@gateway:~# mariadb -V

mariadb from 11.2.5-MariaDB, client 15.2 for debian-linux-gnu (x86_64) using EditLine wrapper

Step 5: Run the following command to secure MariaDB installation and set a root password.

root@gateway:~# mariadb-secure-installation

Step 5(A): This will take you through a series of prompts, allowing you to adjust the security settings for your MariaDB installation. The first prompt will ask for the current root password of the database. If you haven't set one yet, simply press ENTER to indicate none.

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):

Step 5(B): You will then be prompted to set the database root password. This step ensures that no one can log in as the root user without proper authentication.

Switch to unix_socket authentication [Y/n]
Enabled successfully!
Reloading privilege tables..
... Success!

Change the root password? [Y/n] y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success!

Step 5(C): From there, you can press 'Y' and then ENTER to accept the default options for all the remaining questions.

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!

Step 6: Test MariaDB installation. Login to MariaDB with the following command and confirm the connection is successful.

root@gateway:~# mariadb -u root -p
Enter password:

Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 229
Server version: 11.2.5-MariaDB-ubu2204 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)]>
MariaDB [(none)]>