Halloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix NowHalloween DealsAmazon USOctober picks are moving - compare before checkoutAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk9 min

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

A practical, distribution-specific guide to installing MariaDB on a Linux VPS, choosing repositories, handling signing keys, securing defaults, starting the service and testing local access.
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 packages for your distribution, run mariadb-secure-installation, start the mariadb.service unit, and test a local client connection. The commands differ between Debian/Ubuntu and RHEL-family systems, and a fresh MariaDB 10.4-or-newer installation commonly authenticates the local root account through the Unix socket instead of requiring a root password.

This guide covers Debian, Ubuntu, RHEL, CentOS, Fedora and compatible VPS images. It also explains when to use the distribution repository versus MariaDB’s repository, how to handle signing keys, what the hardening prompts mean, and how to diagnose a service that will not start.

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.

Before you install MariaDB

Confirm the operating system

Log in to the VPS over SSH with an account that can use sudo. Identify the distribution before choosing commands. Debian and Ubuntu use APT; RHEL, CentOS and Fedora-family systems use DNF, with YUM still present on some older releases.

On a system you do not recognize, inspect the release information with cat /etc/os-release. Do not mix Debian packages with RPM packages or follow instructions for a different major release: repository metadata, security policy and package names are distribution-specific.

Check practical prerequisites

  • A working SSH session and a user with sudo privileges.
  • Enough disk space for the server package, system tables, logs and the databases you expect to create.
  • Package-manager access to the configured mirrors or repositories.
  • A plan for application connectivity. Keeping the database local to the application avoids opening port 3306 to the public internet.
  • A backup plan before future major-version changes. Installation documentation does not publish a restore percentage, so test that your own backups can be restored in a separate environment.

Choose a MariaDB repository deliberately

Distribution repositories

The repository supplied by Debian, Ubuntu, RHEL, CentOS or Fedora is the simplest installation path. It follows the operating system’s package signing, dependency and update policy, and normally requires no extra repository file. The trade-off is that the MariaDB release may be older than the one maintained by the MariaDB project.

MariaDB’s repository

Use MariaDB’s own repository when the distribution stream is too old for your application or when you specifically need a MariaDB-supported release line. The Debian documentation lists repository coverage for Debian 11, 12, 13 and unstable, plus Ubuntu 22.04 and 24.04. The RPM documentation recommends MariaDB repositories when a later version is required.

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.

Check compatibility with the exact VPS release before adding a repository. A repository intended for another major operating-system version can leave you with unsatisfied dependencies or an unsupported upgrade path. Decide whether the newer release is worth taking on repository-file and signing-key maintenance.

Decision Distribution repository MariaDB repository
MariaDB release Version selected by the VPS distribution; the exact version is not stated here. Choose a MariaDB-supported stream appropriate for the operating system; the exact version depends on the stream selected.
Update cadence Follows the distribution’s maintenance and security policy. Follows MariaDB’s repository cadence and stream policy.
Configuration work Usually just refresh metadata and install packages. Add repository configuration and maintain its signing key.
Security integration Uses the distribution’s normal AppArmor or SELinux policy where provided. Must remain compatible with the VPS operating system’s AppArmor or SELinux policy.
Best fit A straightforward, vendor-integrated deployment. A deliberate choice for a newer or MariaDB-specific release requirement.

Install MariaDB on Ubuntu or Debian

1. Refresh APT metadata

  1. Update the package index:
    sudo apt update
  2. Read any warnings before continuing. If a repository is unreachable, unsigned or aimed at a different release, correct that repository rather than bypassing the warning.

2. Install the server and client packages

For the package set documented for Debian and Ubuntu, run:

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

APT displays the packages, dependencies and disk-space changes before making modifications. Confirm that the proposed versions and repositories match your decision. The exact package set can vary by distribution release; if APT proposes a different dependency set, inspect it instead of forcing the command.

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.

3. If you selected MariaDB’s APT repository

Configure the repository for the exact Debian or Ubuntu release first, then repeat the metadata refresh and installation steps. Current Debian and Ubuntu systems deprecate apt-key; place the MariaDB signing key in the documented keyring location and reference that keyring from the repository definition. Do not copy an old tutorial that pipes a key into apt-key add.

Install MariaDB on RHEL, CentOS, Fedora or Rocky Linux

1. Refresh DNF or YUM metadata

On current RHEL-family systems, update package metadata with:

sudo dnf update

On an older system that uses YUM, use:

sudo yum update

Review the transaction summary. A full metadata update can include operating-system updates unrelated to MariaDB, so schedule it according to your VPS maintenance policy.

2. Install the server packages

Install the documented RPM packages:

sudo dnf install mariadb mariadb-server

If the host uses YUM instead of DNF, use the equivalent YUM install command. Package names and dependencies can differ between RHEL-family releases; accept the transaction only after checking the proposed versions and dependencies.

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

3. If you selected MariaDB’s RPM repository

Add the repository for the exact RHEL-family release and MariaDB stream you chose, then refresh metadata and install the packages. RPM-based setups import the repository signing key. Keep the key current: an existing repository may need the latest MariaDB key after a key rotation. Never disable signature checking merely to make an installation proceed.

Handle repository signing keys safely

Package signatures protect the software you install from a repository. On Debian and Ubuntu, use the current MariaDB keyring-placement method; apt-key is deprecated on current systems. On RHEL-family systems, import the RPM key requested by the repository configuration.

  • Confirm that the key belongs to the repository you intentionally selected.
  • Read package-manager warnings about expired, rotated or missing keys.
  • Update an old MariaDB keyring using the current documented method instead of adding duplicate keys indefinitely.
  • Do not accept unsigned packages or disable signature verification as a workaround.

Run the secure MariaDB installation script

After the packages finish installing, run:

sudo mariadb-secure-installation

The script is an interactive review of common defaults. Read every prompt; the safest answer depends on how this VPS will be used.

Remove anonymous users

Answer the anonymous-user prompt so that accounts without a named login cannot connect. Anonymous accounts are unnecessary for a normal application server and can create confusing privilege behavior.

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

Prevent remote root logins

Reject root accounts that can connect remotely. Administrative access should occur locally over the VPS session or through a controlled private administration path, not through a publicly reachable database listener.

Understand the root-password prompt

Do not assume that setting a root password is mandatory. MariaDB documents Unix-socket authentication as the usual default from MariaDB 10.4. With that method, the operating-system root user (or a user invoking MariaDB through sudo) authenticates locally through the socket, and a password prompt may not be the correct first-login workflow.

If you deliberately configure password authentication for root, record the password in an approved secret store and use the password-based connection shown below. Do not put the password in shell history, a public script or an application configuration file with world-readable permissions.

Review the remaining prompts

Use the script to remove insecure defaults it identifies, while recognizing that the script does not replace operating-system hardening. It does not create your application schema, configure backups or decide whether a remote client should reach port 3306.

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

Check and start MariaDB with systemctl

Inspect the service

On a systemd-based VPS, check the service unit:

sudo systemctl status mariadb

The unit is named mariadb.service. A running service shows an active state and recent log information. If the status screen opens in a pager, press q to exit.

Start a stopped service

If the service is installed but inactive, start it with:

sudo systemctl start mariadb

Run the status command again and look for an active state. If the service stops immediately, do not repeatedly restart it without reading the error details.

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

Inspect startup failures

Check the system journal for the MariaDB unit:

sudo journalctl -u mariadb

Look for a clear cause such as a configuration typo, an unavailable data directory, a permission problem, a full filesystem, a port conflict or a failed dependency. Correct the underlying issue, then start MariaDB again and verify its status. After a VPS reboot, include systemctl status mariadb in your operational check so a failed startup is noticed before an application reports a database outage.

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

Verify a local connection

Socket-authenticated root account

On a fresh installation using the documented Unix-socket default, connect locally with:

sudo mariadb

A MariaDB prompt confirms that the client can reach the server and that the local administrative authentication method works. Exit with exit or quit.

Password-authenticated root account

If you configured a password-authenticated root account, use:

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

mariadb -u root -p

Enter the password when prompted. Keeping the password out of the command line prevents it from appearing in process listings or shell history.

Interpret a failed connection

  • “Can’t connect to local server”: check sudo systemctl status mariadb, then inspect sudo journalctl -u mariadb.
  • Access denied with sudo mariadb: the root account may use password authentication instead of the socket method; try the password form you configured.
  • Access denied with -p: verify the account’s authentication method and password without exposing the password in a command.
  • Connection works locally but not remotely: that is expected when the server is bound for local use or the firewall blocks port 3306. Decide whether remote access is actually required before changing either setting.

Apply operational security after installation

Keep port 3306 private by default

Leave the VPS firewall closed to database port 3306 unless a specific remote client genuinely requires it. Prefer an application on the same VPS or a private network connection. If remote administration is necessary, restrict the source addresses and use the narrowest network path available; do not expose a database port to the whole internet for convenience.

Create an application-specific account

Applications should not connect as root. After logging in locally as an administrator, create a database and a least-privilege account appropriate to the application. For example, replace the sample names and password with values stored securely:

CREATE DATABASE appdb;
CREATE USER 'appuser'@'localhost' IDENTIFIED BY 'use-a-long-unique-secret';
GRANT ALL PRIVILEGES ON appdb.* TO 'appuser'@'localhost';
FLUSH PRIVILEGES;

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

Grant only the privileges the application needs. If the application runs on another host, use a private network and an explicitly restricted host pattern rather than changing the account to permit connections from everywhere.

Account for AppArmor or SELinux

Debian and Ubuntu commonly enforce AppArmor policies, while RHEL-family systems commonly use SELinux. These controls can deny file or network operations that would otherwise appear valid. Keep the distribution’s policy packages aligned with the operating system and investigate policy-denial messages before disabling a control.

Back up before upgrades

Take a known-good backup before a major MariaDB or operating-system change, and practice restoring it on a separate environment. A backup that has never been restored is an assumption, not a verified recovery plan.

Debian/Ubuntu and RHEL-family choices at a glance

Area Debian or Ubuntu VPS RHEL, CentOS, Fedora or Rocky Linux VPS
Metadata command sudo apt update sudo dnf update, or sudo yum update on older systems
Install command sudo apt install mariadb-server mariadb-client galera-4 sudo dnf install mariadb mariadb-server
Repository-key method Current keyring placement; apt-key is deprecated RPM key import and key-rotation maintenance
Typical policy control AppArmor may be present SELinux may be present
Service unit mariadb.service mariadb.service
First local root test sudo mariadb when socket authentication is enabled sudo mariadb when socket authentication is enabled

The table shows the documented command paths, not a promise that every derivative distribution exposes identical package versions or defaults. Confirm the transaction proposed by your own package manager.

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

Installation checklist

  • Distribution identified and its package metadata refreshed.
  • Repository choice made deliberately, with compatibility checked.
  • MariaDB packages installed and dependency changes reviewed.
  • Signing keys handled with current APT or RPM methods.
  • sudo mariadb-secure-installation completed and remote root access rejected.
  • sudo systemctl status mariadb reports an active service.
  • A local connection succeeds using the configured socket or password method.
  • Port 3306 remains private unless a documented application requirement says otherwise.
  • An application-specific account and a tested backup plan are in place.

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 from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
PC Slower Than It Used to Be?Free scan - under a minute

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.