How to Install MariaDB on Oracle Linux 9
Install MariaDB Server on Oracle Linux 9 with DNF, start the service, use local socket-based administration, and create a least-privilege account.
On this page
This guide installs the MariaDB Server package from the repositories enabled for Oracle Linux 9. The available MariaDB version depends on the configured Oracle Linux package stream; check the candidate on your system before installing. Oracle Linux 9 uses DNF to manage these repositories and packages.
Prerequisites
- An Oracle Linux 9 system with its intended BaseOS and AppStream repositories enabled.
- A user account with
sudoprivileges.
If package metadata is unavailable or DNF cannot find the server package, check the enabled repositories with dnf repolist and the available MariaDB streams with dnf module list mariadb. For stream lifecycle details, see Oracle’s Oracle Linux 9 Application Streams documentation.
Install MariaDB Server
Installing MariaDB does not require upgrading every package on the system. Apply operating-system updates separately according to the server’s maintenance plan. Before installing, check the available server version and module streams:
sudo dnf info mariadb-server
sudo dnf module list mariadb
Oracle Linux 9.8 introduced the mariadb:11.8 module stream. If dnf module list shows that stream and you want it for a new installation, enable it before installing the server package. Do not switch an existing database to another stream without a planned upgrade and backup. See Oracle’s 9.8 release notes and DNF module command reference.
sudo dnf module enable mariadb:11.8
Then install the package. DNF uses the enabled or default stream.
sudo dnf install mariadb-server
Start MariaDB and check the service
Enable MariaDB at boot and start it now:
sudo systemctl enable --now mariadb
sudo systemctl status mariadb --no-pager
Verify local administrative access
On Linux, MariaDB 10.4 and later commonly use the unix_socket authentication plugin for root@localhost. On such installations, use the operating-system root account for local administration:
sudo mariadb
At the MariaDB prompt, check the server version and current identity:
SELECT VERSION();
SELECT USER(), CURRENT_USER();
Do not assume a root password must be set. MariaDB documents the 10.4 authentication changes and Unix socket authentication.
Review the installation security options
Run the interactive hardening helper if it is available in the installed package:
sudo mariadb-secure-installation
Some packages also provide the older mysql_secure_installation command. Review each prompt for the current installation, including whether to remove anonymous accounts and the test database and whether remote root access is allowed. The script can set a root password, but that is not necessarily required when local root authentication uses unix_socket. See MariaDB’s secure installation guidance.
Create a database and application account
Connect locally as the administrator and create a database plus an account with only the row-level privileges shown here. Replace the account name and password placeholder with values appropriate for your application:
CREATE DATABASE mydatabase;
CREATE USER 'myuser'@'localhost'
IDENTIFIED BY 'replace-with-a-unique-secret';
GRANT SELECT, INSERT, UPDATE, DELETE
ON mydatabase.* TO 'myuser'@'localhost';
This account can work with rows in mydatabase but cannot create or alter schema objects. Use a separate migration account for schema changes. Exit the SQL client with exit;.
Test the application account from the shell:
mariadb --user=myuser --password --database=mydatabase
Enter its password at the prompt. For more setup and SQL examples, browse the MariaDB tutorial and MariaDB Reference.