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:
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> You need a user account with sudo or root access to follow these steps.
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> Run <code>sudo mysql_secure_installation</code> 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
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.
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> 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.
Apache is one of the most widely used open-source web servers in the world. It is…
Swap space is an area on disk that Linux uses when it runs out of physical…
Zoom is one of the most widely used video conferencing platforms. Zoom works on Windows, macOS,…
Webmin is an open-source web-based control panel for Linux servers. It gives you a browser interface…
Corruption investigations need accuracy, patience, and strong evidence. In 2026, OSINT tools can help researchers,…
Private investigators use OSINT to collect public information, verify identities, review business connections, check public…