How To

Install MariaDB on Ubuntu 20.04: Setup and Admin Access

MariaDB is an open-source relational database management system. It was created by the original MySQL developers as a community-driven fork, and it works as a drop-in replacement for MySQL. Most apps that support MySQL run on MariaDB without any code changes.

MariaDB is commonly used for:

  • Web applications and CMS platforms like WordPress
  • LAMP and LEMP stack setups on Linux servers
  • Any project that previously ran on MySQL

This guide shows you how to install MariaDB on Ubuntu 20.04, log in as root, and set up admin access for external tools like phpMyAdmin.

<strong>Prerequisite:</strong>&nbsp;You need a user account with sudo or root access to follow these steps.

Install MariaDB on Ubuntu 20.04

The latest version of MariaDB available in Ubuntu’s default repositories is version 10.3. Install it with:

bashsudo apt updatesudo apt install mariadb-server

The service starts on its own after install. Check that it is running:

bashsudo systemctl status mariadb

You should see active (running) in the output. The database server is ready to use.

<strong>Tip:</strong>&nbsp;Run&nbsp;<code>sudo mysql_secure_installation</code>&nbsp;to harden your setup. It walks you through removing test databases, disabling anonymous logins, and setting a root password.

Check the installed version at any time with:

bashmariadb --version

To start, stop, or restart MariaDB, use these commands:

bashsudo systemctl start mariadbsudo systemctl stop mariadbsudo systemctl restart mariadb

Log In to MariaDB as Root

By default, MariaDB uses the auth_socket plugin for the root user. This means root does not log in with a password. Instead, MariaDB checks that the Linux system user running the command matches the database user name.

In simple terms, if you have sudo access on the server, just run:

bashsudo mysql

You will see the MariaDB prompt:

MariaDB [(none)]>

Type exit or press CTRL+D to close the session.

This way of logging in works well when you manage MariaDB from the server terminal directly. No password is sent over the network, which makes it secure by default.

The problem comes when you use an external tool like phpMyAdmin. Those tools connect with a username and password, which auth_socket does not support.

Set Up an Admin User for External Access

If you need to connect from an external program, you have two options.

Option 1: Change the root login method.

This lets the root user log in with a password. Run these commands from inside the MariaDB shell:

sqlALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'your_strong_password';FLUSH PRIVILEGES;

Option 2 (recommended): Create a new admin user.

This keeps root on auth_socket and gives you a separate account for external tools. It is the safer approach:

sqlGRANT ALL PRIVILEGES ON *.* TO 'admin'@'localhost' IDENTIFIED BY 'your_strong_password';

You can name this user anything you like. Just make sure to use a long, strong password.

After making any changes, restart MariaDB:

bashsudo systemctl restart mariadb
<strong>Tip:</strong>&nbsp;Never reuse passwords for database admin accounts. Use a random, unique password and store it in a password manager.

MariaDB is now installed and running on your Ubuntu server. The default setup is secure for most use cases. If you plan to connect a web application, create a dedicated database user with access to only that application’s database, not the full server. Got questions? Leave a comment below.

Cyber Defence

Recent Posts

Install Apache on Ubuntu 20.04: Setup and Virtual Host Guide

Apache is one of the most widely used open-source web servers in the world. It is…

27 minutes ago

Add Swap Space on Ubuntu 20.04: Create, Enable, and Tune

Swap space is an area on disk that Linux uses when it runs out of physical…

34 minutes ago

Install Zoom on Ubuntu 20.04: Download, Setup, and Remove

Zoom is one of the most widely used video conferencing platforms. Zoom works on Windows, macOS,…

40 minutes ago

Install Webmin on Ubuntu 20.04: Complete Setup and Login Guide

Webmin is an open-source web-based control panel for Linux servers. It gives you a browser interface…

46 minutes ago

Best OSINT Tools for Investigating Corruption 2026: Public Records and Link Analysis

Corruption investigations need accuracy, patience, and strong evidence. In 2026, OSINT tools can help researchers,…

1 hour ago

Best OSINT Tools for Private Investigators 2026: Legal People and Asset Research

Private investigators use OSINT to collect public information, verify identities, review business connections, check public…

1 hour ago