Follow through this guide to learn how to install MariaDB 11 on Ubuntu 24.04. “MariaDB 11 is the new major release series of MariaDB. It ships with several entirely new features and improvements“.
Table of Contents
Installing MariaDB 11 on Ubuntu 24.04
Run System Update
Update and upgrade your system package cache.
sudo apt update
Installing MariaDB 11 on Ubuntu 24.04
Install MariaDB 11 from APT Repository
Default Ubuntu 24.04 repos currently do not have MariaDB 11.x
apt show mariadb-server
mariadb-server:
Installed: 1:10.11.7-2ubuntu2
Candidate: 1:10.11.7-2ubuntu2
Version table:
*** 1:10.11.7-2ubuntu2 500
500 http://de.archive.ubuntu.com/ubuntu noble/universe amd64 Packages
100 /var/lib/dpkg/status
The version of MariaDB available on Ubuntu 24.04 default repositories is is MariaDB 10.11 as you can see in the command output above.
Therefore, to install MariaDB 11, you need to MariaDB APT repository as follows:
sudo apt install software-properties-common dirmngr curl ca-certificates apt-transport-https
To Install MariaDB 11 APT repository, we will use the MariaDB package repository setup script which allows you to choose the version of MariaDB you want to set the APT repositories for.
Unfortunately, MariaDB APT repositories similarly are not available for Ubuntu 24.04 Noble Numbat as of this writing. So if you really need to run the latest stable release version of MariaDB on Noble Numbat, you just have to use APT repos for Ubuntu 22.04 Jammy by executing the command below;
curl -LsS https://r.mariadb.com/downloads/mariadb_repo_setup | \
sudo bash -s -- --mariadb-server-version="mariadb-11.3" \
--os-type="ubuntu" \
--os-version="jammy"
Normally, the script automatically detects the OS type and the version and checks if it is supported or not.
For example, you would simply just execute it as follows;
curl -LsS https://r.mariadb.com/downloads/mariadb_repo_setup | \
sudo bash -s -- --mariadb-server-version="mariadb-11.3"To check more information on how to use the script, see the help page.
MariaDB APT Repository Setup Scriptcurl -LsS https://r.mariadb.com/downloads/mariadb_repo_setup | bash -s -- --help
Sample script output;
# [info] Skipping OS detection and using OS type 'ubuntu' and version 'jammy' as given on the command line
# [info] Checking for script prerequisites.
# [info] MariaDB Server version 11.3 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
Installing MariaDB 11 on Ubuntu 24.04;
You should now be able to install MariaDB 11 by running the command below;
sudo apt install mariadb-server
Verify the MariaDB installed version
MariaDB 11 deprecates the use of mysql
command line tool and replaces it with mariadb
.
As much as you can still be able to use mysql command, you will get some deprecation warnings.
To check the version of installed MariaDB, run the command below;
mariadb -V
mariadb from 11.3.2-MariaDB, client 15.2 for debian-linux-gnu (x86_64) using EditLine wrapper
Running MariaDB 11 on Ubuntu 24.04
Upon installation, MariaDB is started and enabled to run on system boot;
systemctl status mariadb
● mariadb.service - MariaDB 11.3.2 database server
Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; preset: enabled)
Drop-In: /etc/systemd/system/mariadb.service.d
└─migrated-from-my.cnf-settings.conf
Active: active (running) since Sun 2024-05-12 18:18:13 UTC; 50s ago
Docs: man:mariadbd(8)
https://mariadb.com/kb/en/library/systemd/
Process: 27007 ExecStartPre=/usr/bin/install -m 755 -o mysql -g root -d /var/run/mysqld (code=exited, status=0/SUCCESS)
Process: 27009 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
Process: 27011 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= || VAR=`cd /usr/bin/..; /usr/bin/galera_recovery`; [ $? -eq 0 ] && systemct>
Process: 27085 ExecStartPost=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
Process: 27087 ExecStartPost=/etc/mysql/debian-start (code=exited, status=0/SUCCESS)
Main PID: 27071 (mariadbd)
Status: "Taking your SQL requests now..."
Tasks: 14 (limit: 30453)
Memory: 102.3M (peak: 107.2M)
CPU: 1.457s
CGroup: /system.slice/mariadb.service
└─27071 /usr/sbin/mariadbd
May 12 18:18:13 noble mariadbd[27071]: 2024-05-12 18:18:13 0 [Note] InnoDB: log sequence number 46980; transaction id 14
May 12 18:18:13 noble mariadbd[27071]: 2024-05-12 18:18:13 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
May 12 18:18:13 noble mariadbd[27071]: 2024-05-12 18:18:13 0 [Note] Plugin 'FEEDBACK' is disabled.
May 12 18:18:13 noble mariadbd[27071]: 2024-05-12 18:18:13 0 [Note] Plugin 'wsrep-provider' is disabled.
May 12 18:18:13 noble mariadbd[27071]: 2024-05-12 18:18:13 0 [Note] InnoDB: Buffer pool(s) load completed at 240512 18:18:13
May 12 18:18:13 noble mariadbd[27071]: 2024-05-12 18:18:13 0 [Note] Server socket created on IP: '127.0.0.1'.
May 12 18:18:13 noble mariadbd[27071]: 2024-05-12 18:18:13 0 [Note] mariadbd: Event Scheduler: Loaded 0 events
May 12 18:18:13 noble mariadbd[27071]: 2024-05-12 18:18:13 0 [Note] /usr/sbin/mariadbd: ready for connections.
May 12 18:18:13 noble mariadbd[27071]: Version: '11.3.2-MariaDB-1:11.3.2+maria~ubu2204' socket: '/run/mysqld/mysqld.sock' port: 3306 mariadb.org binary distribut>
May 12 18:18:13 noble systemd[1]: Started mariadb.service - MariaDB 11.3.2 database server.
You can manage the service via systemctl command.
For example, to start MariaDB service;
sudo systemctl start mariadb
To restart;
sudo systemctl restart mariadb
To stop the service;
sudo systemctl stop mariadb
Enable the service from running on system boot;
sudo systemctl enable mariadb
Disable the service from running on system boot;
sudo systemctl disable mariadb
Securing MariaDB 11
MariaDB comes with a default security script, mariadb-secure-installation
that is used to improve the security of MariaDB installation by:
- Setting the password for root accounts (if need be).
- Disabling remote root login to the databases.
- Removing anonymous-user accounts.
- Removing the test database, which by default can be accessed by anonymous users.
Simply run the command below to launch the script.
sudo mariadb-secure-installation
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]
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]
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]
... 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]
... 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]
- 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]
... 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!
MariaDB Authentication
The new installations of MariaDB have two secure accounts are created during the installation.
The accounts are root@localhost
and mysql@localhost
.
Both accounts uses either of the unix_socket
and the mysql_native_password
authentication plugins.
unix_socket
authentication plugin allows a system root
user or a user with sudo rights
to login as root@locahost
to MariaDB database without a password.
With unix_socket
authentication plugin, while being a root user, you can simply login by running either of the commands below;
mariadb
or
mariadb -u root
If you are a non-root user with sudo account;
sudo mariadb
Or;
sudo mariadb -u root
Even if you run, mariadb -u root -p
, and press ENTER for blank password, you will still login.
You can also login as mysql user;
sudo -u mysql mariadb
Enable MariaDB password Authentication
With the two privileged accounts, root@localhost
and mysql@localhost
, anyone with access to it can login to MariaDB.
It is not recommended to leave such user accounts with no password and all privileges, as this can pose a significant security risk to your database.
The two accounts above uses mysql_native_password
plugin by default;
sudo mariadb
select User,Host,plugin from mysql.user;
MariaDB [(none)]> select User,Host,plugin from mysql.user;
+-------------+-----------+-----------------------+
| User | Host | plugin |
+-------------+-----------+-----------------------+
| mariadb.sys | localhost | mysql_native_password |
| root | localhost | mysql_native_password |
| mysql | localhost | mysql_native_password |
| dvwa | localhost | mysql_native_password |
+-------------+-----------+-----------------------+
4 rows in set (0.001 sec)
MariaDB [(none)]>
The mysql_native_password
plugin is used as a failover for the unix_socket
plugin. Even if you have setup a password using MariaDB secure installation script, you can still login as those accounts without a password.
show grants for root@localhost;
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Grants for root@localhost |
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO `root`@`localhost` IDENTIFIED VIA mysql_native_password USING '*9C6C35530EE4427B07D2FA4F9E119C3915D18940' OR unix_socket WITH GRANT OPTION |
| GRANT PROXY ON ''@'%' TO 'root'@'localhost' WITH GRANT OPTION |
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
2 rows in set (0.000 sec)
show grants for mysql@localhost;
+------------------------------------------------------------------------------------------------------------------------------------------+
| Grants for mysql@localhost |
+------------------------------------------------------------------------------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO `mysql`@`localhost` IDENTIFIED VIA mysql_native_password USING 'invalid' OR unix_socket WITH GRANT OPTION |
| GRANT PROXY ON ''@'%' TO 'mysql'@'localhost' WITH GRANT OPTION |
+------------------------------------------------------------------------------------------------------------------------------------------+
2 rows in set (0.000 sec)
As you can see above, we had already set the password for root user using the mysql_secure_installation command. But mysql user account has invalid password.
Thus, enable password authentication.
ALTER USER root@localhost identified by 'myStr0nP@ssW0rd';
ALTER USER mysql@localhost identified by 'myStr0nP@ssW0rd2';
flush privileges;
quit
This re-enables the MariaDB password authentication and hence, you can now login as non root or non sudo user.
sudo mariadb
Sample output;
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
Or;
sudo -u mysql mariadb
ERROR 1045 (28000): Access denied for user 'mysql'@'localhost' (using password: NO)
Provide a password to be able to login;
mariadb -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 61
Server version: 11.3.2-MariaDB-1:11.3.2+maria~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)]>
Set Native Password Authentication Method as Default
When you set the password above, it completely disables unix_socke
t authentication plugin and instead use the msqyl_native_password
authentication method;
show grants for root@localhost;
+----------------------------------------------------------------------------------------------------------------------------------------+
| Grants for root@localhost |
+----------------------------------------------------------------------------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO `root`@`localhost` IDENTIFIED BY PASSWORD '*73E1DDB4DA8B34D3080B082A8DFC863A56285DD4' WITH GRANT OPTION |
| GRANT PROXY ON ''@'%' TO 'root'@'localhost' WITH GRANT OPTION |
+----------------------------------------------------------------------------------------------------------------------------------------+
2 rows in set (0.001 sec)
show grants for mysql@localhost;
+-----------------------------------------------------------------------------------------------------------------------------------------+
| Grants for mysql@localhost |
+-----------------------------------------------------------------------------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO `mysql`@`localhost` IDENTIFIED BY PASSWORD '*4C8C1832BBF14A360C2F70EA14CBD912AE0AF280' WITH GRANT OPTION |
| GRANT PROXY ON ''@'%' TO 'mysql'@'localhost' WITH GRANT OPTION |
+-----------------------------------------------------------------------------------------------------------------------------------------+
2 rows in set (0.001 sec)
That marks the end of our guide on installing MariaDB 11 on Ubuntu 24.04.
Other Tutorials
You can check our other MySQL/MariaDB related tutorials.