Skip to content

Setting Up Databases on a Linux Server – Deploying and Managing Database Services

Discover how to install and configure various databases on Ubuntu and other Linux distributions for improved performance and security → Learn more now

12 November 20265 min read33 Views0 helpful

Introduction

This guide shows you how to install different types of databases. We use Ubuntu 20.04 as the operating system example, but also provide the corresponding commands for other Linux distributions available on our website. These commands must be executed via SSH. If you don’t know how to connect to your server via SSH, please check here: Initial Access (SSH).

Installing Databases with One-Click Apps

You can install databases directly via One-Click Apps in the dashboard of your dedicated server. After the initial setup of the apps, open the app catalog, search for databases, and start the installation with your preferred project, environment, and domain settings. This allows you to quickly and easily deploy and manage databases without manually working in the command line – while still benefiting from integrated web management, custom domain support, and SSL provisioning where available.

Preparation

Before starting the installation of a database, make sure your system is up to date. Update your package manager’s packages with the following command depending on your operating system:

Code
// Ubuntu & Debian
sudo apt update

// CentOS
sudo yum update

// OpenSUSE
sudo zypper up

// Fedora
sudo dnf upgrade --refresh

Database Types

Depending on which database service you want to install, follow the appropriate instructions:

What is MariaDB?

MariaDB is an open-source relational database management system, originally forked from MySQL. It offers improved performance, security, and continuous development. Notable features include enhanced storage engines and full compatibility with MySQL. We recommend MariaDB over MySQL.

MariaDB Installation

First, ensure that the latest MariaDB version is installed. Some older operating systems like Debian 9 or Ubuntu 18.04 do not provide the latest MariaDB version by default in their package managers. Use the following command to ensure the latest version is used:

Code
curl -sS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | sudo bash

After installing the repo, update the package manager cache as described in the preparation step.

Info

You can safely skip installing the MariaDB repo (above) on modern operating systems like Ubuntu 22.04 or Debian 11.

Once the repo is set up, install MariaDB by installing the mariadb-server package. Depending on your OS, run one of the following commands:

Code
// Ubuntu & Debian
sudo apt install mariadb-server

// CentOS
sudo yum install mariadb-server

// OpenSUSE
sudo zypper install mariadb

// Fedora
sudo dnf install mariadb-server

MariaDB Configuration

After installation, start configuring the server with the following command:

Code
mysql_secure_installation

Now you can configure your MariaDB (MySQL) server by following the instructions and setting a password for your server. You can skip the first prompt by pressing Enter.

Info

The root user is the main user of your MariaDB (MySQL) server!

Next, you will be asked if you want to set a password for the root user. Confirm with y for yes. Then enter the new root password.

Info

Nothing will be displayed while typing the password – this is normal and your password will still be saved. Use a strong password for root and keep it safe.

You will then be asked whether to remove anonymous users from the server. For security reasons, confirm this with y:

Next, decide whether the root user is allowed to connect remotely to the server. For security reasons, disable this option and confirm with y:

Then you can remove the test database that MariaDB ships with by confirming with y, as it is not needed:

At the end, you will be asked if the database privileges should be reloaded. Confirm with y to activate the previously set root password:

Your MariaDB (MySQL) server is now ready to use!

What is Redis?

Redis is an in-memory data store that primarily stores data in key-value format but also supports other formats like lists, JSON, and more. It is known for its speed and delivers responses to requests within milliseconds.

Redis Installation

First, you need to add a repository that enables Redis installation. This step is not necessary for all Linux distributions, only for those listed below. Run the command that matches your OS and version:

Code
// Ubuntu (all versions) and Debian (only Debian 10)
curl -fsSL https://packages.redis.io/gpg | sudo gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/redis.list

// CentOS (only CentOS 7)
sudo yum install epel-release

// CentOS (only CentOS 8)
sudo dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm

After adding the repo, update the package manager cache as described in the preparation step.

Info

If your operating system is not listed above, you can skip this step.

After adding the repo, install the Redis server package. Run the command that matches your OS:

Code
// Ubuntu and Debian
sudo apt install redis-server

// CentOS
sudo yum install redis

// OpenSUSE
sudo zypper install redis

// Fedora
sudo dnf install redis

After installation, your Redis server is ready! By default, it runs on 127.0.0.1:6379 without a password.

Warning

For Debian/Ubuntu users: Remember to enable the redis-server service after installation so it starts automatically on server boot. Use the following command:

Code
sudo systemctl enable --now redis-server

What is MongoDB?

MongoDB is a document-oriented NoSQL database designed for scalability and developer agility. It stores data in a JSON-like BSON format, allowing storage of diverse data types. MongoDB supports indexes to reduce response times and stands out by not requiring a predefined schema like MySQL or SQLite, offering flexibility and speed.

MongoDB Installation

Select your operating system from the tabs below to see the appropriate instructions.

Installation on Ubuntu & Debian

First, import the public GPG key for MongoDB with the following command:

Code
curl -fsSL https://pgp.mongodb.com/server-6.0.asc | \
   sudo gpg -o /usr/share/keyrings/mongodb-server-6.0.gpg \
   --dearmor

Then add the MongoDB source to your OS’s source list by running:

Code
echo "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-6.0.gpg ] https://repo.mongodb.org/apt/$(lsb_release -si | awk '{print tolower($0)}') $(lsb_release -sc)/mongodb-org/6.0 main" | sudo tee /etc/apt/sources.list.d/mongodb-org-6.0.list

Now update the package sources with sudo apt update. Then install MongoDB with:

Code
sudo apt install mongodb-org

Your MongoDB installation should now be working!

Installation on CentOS & Fedora

First, set up the MongoDB repo for Red Hat systems.

Create a file named /etc/yum.repos.d/mongodb-org-6.0.repo and add the following content:

Code
[mongodb-org-6.0]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/6.0/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-6.0.asc

Now install MongoDB. The install command differs slightly between CentOS and Fedora; use the appropriate one:

Code
// CentOS
sudo yum install -y mongodb-org

// Fedora
sudo dnf install -y mongodb-org

Your MongoDB installation should now be running – much simpler than on other Linux distributions!

Installation on OpenSUSE

First, import the public key for the MongoDB repository with:

Code
sudo rpm --import https://www.mongodb.org/static/pgp/server-6.0.asc

Then add the MongoDB repository with:

Code
sudo zypper addrepo --gpgcheck "https://repo.mongodb.org/zypper/suse/15/mongodb-org/6.0/x86_64/" mongodb

Finally, install the latest MongoDB version with:

Code
sudo zypper -n install mongodb-org

Your MongoDB installation should now be ready to use!

FAQ

Frequently asked questions

You can install databases directly via One-Click Apps in the dashboard of your dedicated server by searching for databases in the app catalog and starting the installation with your preferred project, environment, and domain settings.
Make sure your system is up to date by updating your package manager’s packages (e.g., sudo apt update on Ubuntu/Debian).

Feedback

Was this article helpful?

Your feedback helps us prioritize and improve content.

0 of 0 Users found this article helpful.

Personal support

Need more help than the guide provides?

Our ZAP support team knows your product — briefly describe your issue and we'll help you personally.

Zappy knows this guide and answers you right in the chat.