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.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

Install MariaDB from your VPS distribution’s repository unless you specifically need a newer MariaDB release, then run mariadb-secure-installation, start mariadb.service, and test a local login. Debian and Ubuntu use APT; RHEL, CentOS, Rocky Linux and Fedora-family systems use DNF (or YUM on older releases). The procedure below covers repository choice, signing keys, hardening, authentication, service checks and the operational precautions that keep a database from being exposed unnecessarily.

What you need before installing

You need an active Linux VPS, an SSH account with sudo rights, and enough free disk space for the server package, system tables and your data. Perform the work in a maintenance window if the VPS already hosts production services. Keep a second SSH session open while changing packages or firewall rules so a mistake does not lock you out.

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

Identify the operating system

Run:

cat /etc/os-release

Look at ID, VERSION_ID and the release name. Debian and Ubuntu use the APT branch in this guide. RHEL, CentOS, Rocky Linux and Fedora-family distributions use the RPM branch. Do not mix repositories or package commands between these families: a repository built for one release can install incompatible libraries or leave upgrades unsupported.

Decide where MariaDB packages should come from

The distribution repository is normally the least complicated choice. It follows the operating system’s update and security process and needs little repository configuration. MariaDB’s own repository is appropriate when the distribution version is too old or when you need a MariaDB-supported release stream that the VPS vendor does not provide.

Decision factor Distribution repository MariaDB repository
MariaDB release Version selected by the Linux distribution; it may lag upstream. Lets you select a MariaDB-supported stream when a later release is required.
Update cadence Follows the distribution’s package and security policy. Follows MariaDB’s repository cadence and requires you to track its stream.
Configuration effort Usually install immediately after refreshing package metadata. Requires repository files and signing-key configuration before installation.
Security policy Integrates with the distribution’s controls, such as AppArmor on Debian/Ubuntu or SELinux on RHEL-family systems. Still uses the operating system’s security controls, but repository and compatibility choices are your responsibility.
Best fit A conventional VPS where the packaged MariaDB version meets the application requirement. A documented requirement for a newer or specific MariaDB release.

MariaDB’s Debian documentation lists repository coverage for Debian 11, Debian 12, Debian 13, Debian unstable, Ubuntu 22.04 and Ubuntu 24.04. The RPM guidance recommends MariaDB repositories when a later version is needed. Check that your exact VPS release is covered before adding a repository; do not assume a repository for a nearby release is interchangeable.

Refresh package metadata

Refresh metadata before installing. This makes the package manager see current versions and dependency information.

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.

Debian or Ubuntu

sudo apt update

Read the output for unreachable mirrors, signature warnings or held packages. An update that ends with repository errors should be fixed before you install MariaDB; otherwise you may select stale or incomplete dependencies.

RHEL, CentOS, Rocky Linux or Fedora

sudo dnf update

On an older release that still uses YUM, run:

sudo yum update

Review the transaction summary. The command may update existing packages as well as metadata, so confirm that the proposed changes fit your maintenance window.

Install MariaDB on Ubuntu VPS or Debian server

Install the Debian-family packages

  1. Refresh metadata with sudo apt update.
  2. Install the server, client and Galera package named by the Debian/Ubuntu installation procedure:
    sudo apt install mariadb-server mariadb-client galera-4
  3. When APT lists dependencies, versions and disk usage, inspect the proposal. Package sets can vary by distribution release; accept only when the proposed changes are expected for this VPS.

mariadb-server supplies the database daemon, mariadb-client supplies command-line client tools, and galera-4 is included in the documented Debian-family package set. Installing these packages does not by itself configure a cluster; clustering is a separate design decision.

Check what APT selected

After installation, you can inspect the candidate and installed versions with:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
apt-cache policy mariadb-server mariadb-client galera-4

If the candidate is older than your application requires, stop before pinning random packages. Decide whether to use MariaDB’s repository for a supported stream instead.

Install MariaDB on RHEL, CentOS or Rocky Linux

Install the RPM-family packages

  1. Refresh packages with sudo dnf update, or sudo yum update on an older system.
  2. Install the server and client package set:
sudo dnf install mariadb mariadb-server

As with APT, read the dependency and transaction summary before confirming. Names and available versions can differ between RHEL-family releases. If DNF cannot find the required stream, do not substitute Debian packages; configure a repository that explicitly supports your operating system and desired MariaDB release.

Confirm the RPM candidate

Use the package manager’s information output to verify the selected release before proceeding:

dnf info mariadb mariadb-server

If your system uses YUM, the equivalent is yum info mariadb mariadb-server. A package that is available but not maintained for your OS release is not a safe repository choice.

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

Configure a MariaDB repository only when you need one

Distribution packages are deliberately simpler. Add MariaDB’s repository when you have a clear requirement for a later or specific MariaDB-supported stream, and document that choice for future administrators.

Debian and Ubuntu repository considerations

Use MariaDB’s repository instructions for the exact Debian or Ubuntu release shown by /etc/os-release. Repository definitions are release-specific, so select the matching codename and package stream. The supported coverage documented for Debian includes versions 11, 12, 13 and unstable; Ubuntu coverage includes 22.04 and 24.04.

RHEL-family repository considerations

Use the RPM instructions for the exact RHEL-compatible release and select the MariaDB stream your application supports. A later stream can provide newer features, but it also creates a longer-term obligation to track stream changes and test upgrades.

Use current signing-key procedures

APT’s historical apt-key workflow is deprecated on current Debian and Ubuntu systems. Follow the current MariaDB instructions that place the signing key in a dedicated keyring and reference that keyring from the repository definition. Avoid copying an old tutorial that imports a key globally.

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

RPM-based systems use RPM key import. Confirm the key’s fingerprint and import it through the documented repository procedure before accepting packages. If a repository reports a signature failure, stop and resolve the key or repository configuration; do not bypass signature checking.

MariaDB has rotated signing keys in the past. An existing repository may therefore require the current keyring even if it worked previously. Treat package-manager signature warnings as a configuration problem, not as an invitation to disable verification.

Run the secure MariaDB installation script

Once packages are installed, run:

sudo mariadb-secure-installation

The script presents interactive choices. Read each prompt because defaults and wording can vary by MariaDB version. Its purpose is to remove insecure defaults, not to replace a complete database security design.

Remove anonymous users

Choose the option that removes anonymous accounts. Anonymous accounts can allow a connection without a named database user and make auditing harder.

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

Prevent remote root logins

Choose the option that removes or disallows root accounts that can connect remotely. Database administration should happen through a controlled local session or a deliberately secured administrative path, not an Internet-exposed root login.

Understand root authentication before setting a password

Do not assume that setting a root password is mandatory. MariaDB documents Unix-socket authentication as the usual default from MariaDB 10.4. With socket authentication, the operating-system root user can authenticate locally through the socket, so sudo mariadb is normally the correct first login. If you deliberately configure password authentication for root, the client command is mariadb -u root -p.

The script’s historical guidance reflects older installations, which is why many online tutorials insist on a root password. Follow the authentication method actually shown by your installation rather than changing it solely to match an old tutorial.

Finish every prompt and reload privileges

Complete the script and allow it to apply its changes. If a prompt is not relevant to your release, keep the documented default only after reading what it does. Record the choices in your deployment notes so a later administrator knows whether root uses a socket or a password.

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

Start MariaDB with systemctl and verify the service

Check the service state

sudo systemctl status mariadb

The systemd unit is mariadb.service. A successful installation normally leaves the service running, but always check rather than assuming.

Start a stopped service

sudo systemctl start mariadb

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

Inspect startup failures

Use the systemd journal for the current boot:

sudo journalctl -u mariadb -b --no-pager

Look for the first fatal message, such as a configuration syntax error, unavailable data directory, permission denial or a port conflict. Correct the underlying problem, then start MariaDB again and recheck its status.

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

Check after a reboot

Reboot testing is useful after package installation or repository changes. After the VPS returns, reconnect over SSH and run sudo systemctl status mariadb. If the service did not come back, inspect the journal for that boot before changing configuration.

Verify a local database connection

Socket-authenticated root

On a fresh MariaDB 10.4-or-newer installation using the usual Unix-socket method, run:

sudo mariadb

A MariaDB prompt confirms that the daemon is reachable and the local authentication method works. Exit with:

exit

Password-authenticated root

If you configured a root password, use:

mariadb -u root -p

Enter the password when prompted. Do not place the password directly in the command line, where it can be exposed in shell history or process listings.

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

Confirm the server version

At the MariaDB prompt, run:

SELECT VERSION();

This confirms which server answered the connection. Compare the result with the package or repository stream you intentionally selected; an unexpected version is a reason to review repository priority before creating application schemas.

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

Create an application account instead of using root

Applications should use a dedicated database and account with only the permissions they need. After connecting as an administrator, adapt this example to your application:

CREATE DATABASE appdb;
CREATE USER 'appuser'@'localhost' IDENTIFIED BY 'change-this-long-random-password';
GRANT ALL PRIVILEGES ON appdb.* TO 'appuser'@'localhost';
FLUSH PRIVILEGES;

Replace the example password with a unique, randomly generated secret before deployment. Use a host value that matches the application’s real connection path. localhost is appropriate when the application runs on the same VPS and uses the local socket or loopback connection; it is not a substitute for designing a private network when the application is on another host.

Keep administrative credentials out of source code and service unit files where ordinary users can read them. Use your operating system’s secret-management process and rotate credentials when staff, applications or hosting environments change.

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

Keep port 3306 private by default

Leave the VPS firewall closed to TCP port 3306 unless a specific remote client genuinely requires database access. An application on the same VPS can normally connect locally, avoiding Internet exposure. For a separate application server, prefer a private network or tightly restricted firewall rule over opening 3306 to the entire Internet.

Firewall policy is operational guidance rather than a MariaDB package default. Check both the VPS provider’s network firewall and the operating system firewall, and document the source addresses, purpose and expiry of any exception. Removing an unused exception is part of decommissioning an application.

AppArmor, SELinux and repository policy

Debian and Ubuntu commonly enforce AppArmor profiles, while RHEL-family systems commonly use SELinux. These controls can deny a file or network operation even when MariaDB’s own configuration appears correct. Do not disable them as a first troubleshooting step. Check the service journal and the operating system’s security-audit messages, then adjust the policy or MariaDB paths according to the distribution documentation.

This is one reason to compare distributions on more than package age. Vendor support windows, security-policy defaults and the amount of repository configuration required all affect the maintenance cost of a VPS database.

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

Troubleshooting common installation failures

Symptom Likely cause What to do
apt install cannot find a package Stale metadata, an unsupported release, or a repository definition that does not match the OS. Run sudo apt update, recheck /etc/os-release, and verify that the selected repository supports that Debian or Ubuntu release.
DNF reports no matching package The required module or repository is not enabled for the RHEL-family release. Confirm the release and package names, then use a MariaDB-supported RPM repository if the distribution stream is insufficient.
Signature or key error An outdated keyring, a rotated MariaDB key, or a repository mismatch. Install the current documented keyring or RPM key, verify its fingerprint, and retry only after signature checks pass.
mariadb.service is failed Configuration syntax, permissions, data-directory problems, security-policy denial, or a port conflict. Read sudo journalctl -u mariadb -b --no-pager; fix the first fatal error and start the service again.
sudo mariadb is denied The installation uses password authentication, or the command is being run by an account that cannot use the socket-authenticated root path. Use mariadb -u root -p when a root password was configured, and verify which authentication method the hardening step selected.
A remote client cannot connect The firewall blocks 3306, the server is intentionally limited to local access, or the account host does not match the client. Prefer a private network; if remote access is required, create a narrowly scoped account and firewall rule, then test from the permitted source.

Plan backups and upgrades before production use

Back up the database before a major MariaDB or operating-system version change, and test a restore in a separate environment. A backup that has never been restored is an assumption, not a recovery plan. Keep the repository choice, package versions, hardening decisions and application-account inventory with the VPS’s deployment records.

When changing repository streams, review release notes and package-manager proposals, test the application against the target MariaDB version, and schedule a rollback path. Do not combine an unplanned database upgrade with unrelated operating-system changes on a production VPS.

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.