Logo

How to Install MariaDB on Ubuntu 24.04

Mar 15, 2024

To install MariaDB on Ubuntu 24.04, follow these steps:

Step 1 : Ensure your package lists are up-to-date by running:

sudo apt update

Step 2 : Install MariaDB by running:

sudo apt install mariadb-server

Step 3 : Secure the MariaDB installation by running:

sudo mysql_secure_installation

Follow the prompts to secure MariaDB:

- Enter root password (leave blank if not set yet).

- Switch to unix_socket authentication: Choose 'Y'.

- Change the root password: Choose 'Y'.

- Remove anonymous users: Choose 'Y'.

- Disallow root login remotely: Choose 'Y'.

- Remove test database and access to it: Choose 'Y'.

- Reload privilege tables now: Choose 'Y'.

Step 4 : Start and enable MariaDB to run on system boot:

sudo systemctl start mariadb
sudo systemctl enable mariadb

Step 5 : Check the status of MariaDB to ensure it's running without issues:

sudo systemctl status mariadb

Step 6 : Access the MariaDB shell:

sudo mysql

Step 7 : Create an admin user and grant necessary privileges. Replace 'admin' and 'password' with your desired username and password:

CREATE USER 'admin'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO 'admin'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;

Congratulations! You have successfully installed and secured MariaDB on Ubuntu 24.04.

Recommended