DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run Scan×
Skip to content
VGSources
Blog

How to Install MariaDB on a Linux VPS (Ubuntu, Debian, Rocky Linux and RHEL)

A practical guide to installing, securing and verifying MariaDB on Ubuntu, Debian, Rocky Linux, RHEL, CentOS and Fedora VPS servers.
Length10 min Posted Quest giverVGSources Team
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To install MariaDB on a Linux VPS, update the operating system’s package metadata, install the MariaDB server, run mariadb-secure-installation, start mariadb.service, and verify a local login. The commands differ between Debian-based systems such as Ubuntu and Debian and RHEL-family systems such as Rocky Linux, AlmaLinux, CentOS Stream and Fedora.

What you need before installing MariaDB

This procedure assumes you have a newly provisioned Linux VPS, a user with sudo privileges, and SSH access. Log in as that administrative user rather than performing routine database work as the operating system’s root account.

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • Supported operating system: Debian, Ubuntu, RHEL, Rocky Linux, AlmaLinux, CentOS Stream or Fedora-family distributions.
  • Administrative access: Every package and service command below uses sudo.
  • Network access: The VPS must be able to reach its configured package repositories.
  • Firewall plan: Keep TCP port 3306 closed to the public internet unless a particular remote client genuinely needs it.

If you do not have a server yet, obtain a Linux VPS first. A small application server can normally connect to MariaDB over the local socket without exposing a database port at all.

Identify the Linux distribution

Package names and commands depend on the distribution. Confirm the operating system before choosing a command set:

cat /etc/os-release

Use the Debian/Ubuntu instructions when the output identifies Debian or Ubuntu. Use the RHEL-family instructions for RHEL, Rocky Linux, AlmaLinux, CentOS Stream and Fedora. Older systems may still provide yum instead of dnf.

Choose a MariaDB repository

Distribution repositories

The distribution’s own repository is the least complicated installation path. It uses packages integrated with the operating system’s update, security and service-management policies. The trade-off is that the MariaDB release can be older than the current upstream series, especially on long-term-support distributions.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

MariaDB’s Debian repository documentation covers Debian 11, Debian 12, Debian 13, Debian unstable, Ubuntu 22.04 and Ubuntu 24.04. The exact package version available from a normal distribution repository depends on the operating-system release and its maintenance policy.

MariaDB’s repository

Use MariaDB’s own repository when you need a later MariaDB series, a MariaDB-supported stream, or a release not supplied by the VPS operating system. The RPM documentation specifically recommends MariaDB repositories when a later version is required.

Before adding a repository, check that it explicitly supports your operating-system release. Mixing repositories for different distributions or codenames can replace core libraries and leave the VPS difficult to update.

Repository and signing-key decisions

  • Choose one primary source for MariaDB packages. Do not add several repositories that provide competing server versions.
  • Read the package manager’s proposed dependency changes before accepting them.
  • On current Debian and Ubuntu systems, do not use the deprecated apt-key workflow. Follow MariaDB’s current instructions for placing its signing key in a dedicated APT keyring and associating that keyring with the repository.
  • On RHEL-family systems, import the RPM signing key required by the repository configuration.
  • If an existing MariaDB repository reports a key-rotation or signature error, update the repository’s current keyring rather than disabling signature verification.

Install MariaDB on Ubuntu or Debian

1. Refresh APT metadata

sudo apt update

This downloads the current package indexes. If APT reports an unreachable repository, a release-codename mismatch or a signature error, fix that repository before installing MariaDB. Do not continue with a partially trusted package source.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

2. Install the server and client

sudo apt install mariadb-server mariadb-client galera-4

mariadb-server provides the database daemon, mariadb-client provides command-line client tools, and the Debian package set shown here includes galera-4. The exact dependency list can vary with the Debian or Ubuntu release. Review the proposed package changes and confirm only when they match your intended installation.

During installation, the package may create and start the systemd service automatically. Treat that as an initial state to verify, not as a substitute for checking the service yourself.

3. Check the service

sudo systemctl status mariadb

The unit is named mariadb.service. A successful status normally shows that it is loaded and active. If it is inactive or failed, start it explicitly:

sudo systemctl start mariadb

To make the service start during later boots on a system where the package did not already enable it, use:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
sudo systemctl enable mariadb

Install MariaDB on Rocky Linux, RHEL, CentOS or Fedora

1. Update DNF metadata and packages

sudo dnf update

On an older installation that does not provide dnf, use:

sudo yum update

Updating first helps the MariaDB packages match the current kernel, libraries and security updates. If the transaction proposes removing unrelated core packages, stop and investigate the enabled repositories.

2. Install the server and client packages

sudo dnf install mariadb mariadb-server

The RPM-family package names differ from Debian’s: mariadb supplies the client tools and mariadb-server supplies the daemon. Fedora and RHEL derivatives can offer different package versions, dependencies or module streams, so inspect the transaction before confirming it.

3. Start and enable the service

sudo systemctl start mariadb
sudo systemctl enable mariadb
sudo systemctl status mariadb

If the status command reports active (running), the server has started. If it reports failed, keep the status output and inspect the journal before trying repeated starts.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Run the secure MariaDB installation script

After the packages are installed, run:

sudo mariadb-secure-installation

The script walks through security-related choices. Its usefulness depends on the MariaDB version and the distribution defaults; MariaDB’s documentation notes that many reasons for the script’s existence no longer apply. Read each prompt instead of blindly accepting an old tutorial’s answer.

Authentication for the root database account

From MariaDB 10.4 onward, Unix-socket authentication is normally the default. With that method, the operating-system account allowed to use sudo can connect locally with sudo mariadb, while a separate database password for the root account is not necessarily required.

If you deliberately configure password authentication for the database root account, the client command becomes:

mariadb -u root -p

Do not set a root password merely because an old guide says it is mandatory. Choose the authentication method that fits how administrators will access this particular VPS, and use an application-specific database account for software.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Remove anonymous users

When the script asks whether to remove anonymous users, accept the removal. Anonymous accounts create identities that applications and administrators do not need and complicate auditing.

Prevent remote root logins

When asked whether remote root logins should be disallowed, accept the restrictive option. Administration should occur through a controlled local session or an approved private management path, not through an internet-exposed database root account.

Record what you selected

Write down the authentication method and the administrative account you chose. This prevents a common failure mode in which an administrator tries a password login against a socket-authenticated root account, or assumes sudo mariadb will work after switching to password-only authentication.

Verify that MariaDB is running and accepts a connection

Check systemd

sudo systemctl status mariadb

Look for an active running state. If the service is stopped, start it with sudo systemctl start mariadb. If it fails immediately, the status output usually includes the first useful error line.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use socket authentication

sudo mariadb

This is the expected first test on a fresh MariaDB installation that retained the usual Unix-socket authentication. At the MariaDB prompt, run a harmless query:

SELECT VERSION();

Exit with:

EXIT;

Use password authentication

mariadb -u root -p

Enter the database root password when prompted, then run SELECT VERSION(); to confirm that the client reached the server. If this fails but sudo mariadb works, the difference is usually the configured authentication plugin rather than a stopped service.

Create a database account for an application

Applications should not connect as the database root account. After logging in with an administrative method, create a database and a narrowly scoped user appropriate to the application. The exact database name, username, host restriction and privileges depend on the application, so do not grant broad privileges or remote access without a specific requirement.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For a web application running on the same VPS, a local account restricted to the local host is generally safer than an account that accepts connections from every address. Keep the credentials in the application’s protected configuration or secret store, not in source code or a public repository.

Keep port 3306 private

MariaDB listens on TCP port 3306 when TCP networking is enabled, but a local application can use the Unix socket instead. Leave the VPS firewall closed to port 3306 unless a defined remote client needs it. If remote access is unavoidable, restrict the firewall rule to the client’s fixed private address or private network, require encrypted connections where appropriate, and avoid permitting database root access.

Socket access and TCP access are separate paths. A successful sudo mariadb test proves local socket access; it does not prove that a remote host can or should connect over TCP.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Debian/Ubuntu versus RHEL-family installations

Decision point Debian or Ubuntu RHEL-family systems
Metadata update sudo apt update sudo dnf update; use sudo yum update on older systems
Install command sudo apt install mariadb-server mariadb-client galera-4 sudo dnf install mariadb mariadb-server
Client package name mariadb-client mariadb
Service unit mariadb.service
Security script sudo mariadb-secure-installation
Mandatory policy framework AppArmor may be part of the distribution’s security policy SELinux may enforce the distribution’s security policy
Repository choice Distribution packages are simplest; MariaDB’s repository covers Debian 11, 12, 13, unstable, Ubuntu 22.04 and Ubuntu 24.04 when a supported upstream stream is needed Distribution packages are simplest; MariaDB’s repository is recommended when a later release is required

Package freshness, vendor support windows, mandatory security policy and repository maintenance are more important than whether the commands look familiar. A distribution package can be the better operational choice even when an upstream repository offers a newer version.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Troubleshoot common installation failures

APT or DNF cannot find a package

  • Confirm the operating-system release with cat /etc/os-release.
  • Run the correct metadata update command again.
  • Check that the repository matches the release codename or major version.
  • Do not install a package from a repository intended for a different distribution.

A signature or signing-key error appears

Do not bypass package signature verification. On Debian and Ubuntu, replace deprecated apt-key configuration with the current dedicated keyring method documented for the MariaDB repository. On RHEL-family systems, import the repository’s current RPM signing key. Key rotations can make an older repository configuration fail even when the package URL itself still exists.

The service will not start

sudo systemctl status mariadb
sudo journalctl -u mariadb --no-pager

Read the first concrete error in the status and journal output. Typical causes include an invalid configuration change, a directory or permission problem, an incomplete package transaction, insufficient disk space or a conflicting process. Correct the reported cause, then start MariaDB again and recheck its status.

The client says access is denied

First determine whether the account uses Unix-socket or password authentication. Try sudo mariadb for the normal fresh-install socket configuration. Use mariadb -u root -p only when password authentication was configured. A valid operating-system password and a valid MariaDB password are not interchangeable.

Remote connections fail

A local login does not prove remote connectivity. Check the application’s host setting, the VPS firewall, any private-network firewall and MariaDB’s bind configuration. Before opening port 3306, confirm that a remote connection is actually required; local socket access is safer for software running on the same VPS.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Post-installation operations checklist

  • Confirm systemctl status mariadb after the first reboot.
  • Keep package metadata and security updates current through the VPS distribution’s normal update process.
  • Preserve repository signing-key hygiene and investigate package-manager warnings.
  • Use a dedicated application database user rather than the root account.
  • Keep port 3306 closed unless a documented remote client requires it.
  • Back up databases before a major MariaDB or operating-system version change.
  • Test restores in a separate environment; a backup that has never been restored is not a verified recovery plan.
  • Review the systemd journal whenever MariaDB fails after a reboot or package update.

Updating MariaDB without losing control of the VPS

Stay within the release stream supported by the selected repository. Before changing to MariaDB’s repository or moving between major versions, take a verified backup, record the current MariaDB version and repository configuration, and test the planned change on a separate system when possible.

Do not mix a distribution repository and an upstream repository casually. Different streams can have different defaults, dependency requirements and upgrade paths. If you change sources, review the complete package transaction and make sure the signing key and operating-system release are correct.

Quick command reference

Task Debian/Ubuntu RHEL-family
Update metadata sudo apt update sudo dnf update
Install packages sudo apt install mariadb-server mariadb-client galera-4 sudo dnf install mariadb mariadb-server
Run hardening sudo mariadb-secure-installation
Check service sudo systemctl status mariadb
Start service sudo systemctl start mariadb
Enable at boot sudo systemctl enable mariadb
Socket login sudo mariadb
Password login mariadb -u root -p

Frequently Asked Questions

Do I have to set a MariaDB root password?

No. MariaDB normally uses Unix-socket authentication for the root database account from MariaDB 10.4, so a fresh installation may be administered with sudo mariadb. Set and use a password only when password authentication is the deliberate configuration.

What is the MariaDB service name on systemd?

The unit is mariadb.service. Check it with sudo systemctl status mariadb and start it with sudo systemctl start mariadb.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Should I expose port 3306 on my VPS?

Usually not. An application on the same VPS can use the local Unix socket. Keep port 3306 closed unless a specific remote client needs database access, and then restrict the firewall rule to a trusted private address or network.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More quests from Patch Notes

  1. How to Set Up a RedM (RDR2) Server in 2026: License Key, txAdmin and server.cfg, Step by StepBlog11min
  2. Best RedM (RDR2) Server Hosting in 2026: Comparing Four Hosts on Slots, Memory and PriceBlog10min
  3. How to Host a Mindustry Server in 2026: server-release.jar, Port 6567 and the Commands That MatterBlog7min
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.