Log inSign up

Databases guides

MySQL, MariaDB, PostgreSQL, MongoDB, Redis and more, with backups, users and replication. 28 guides in this topic.

Install MySQL 8

Install MySQL 8 from the right source on Ubuntu, Debian, Rocky or Alma, lock it down, add app users and reach it safely through an SSH tunnel.

Install MariaDB

Install MariaDB from your distro or the MariaDB repository, secure the root account, create users and keep the server private on your VPS.

Install PostgreSQL

Install PostgreSQL from distro packages or the PGDG repository, create roles, set pg_hba rules and choose where the server listens.

Install MongoDB

Install MongoDB Community from the official repository, switch on authentication, keep bindIp local and test with mongosh.

PostgreSQL JSON, arrays and special types

Store and query jsonb, arrays, hstore, UUIDs, enums, time zones and ranges in PostgreSQL, with SQL you can paste into psql.

PostgreSQL views, triggers and CTEs

Build views and materialized views, write trigger functions, use CTEs and recursive queries, and branch with CASE in PostgreSQL.

PostgreSQL full-text search and encryption

Add ranked full-text search with tsvector and GIN, encrypt sensitive columns with pgcrypto, and run distance queries in PostgreSQL.

MySQL keys, indexes and full-text search

Design primary and composite keys, link tables for many-to-many data, read EXPLAIN plans and add FULLTEXT search in MySQL 8.

MySQL JSON, views and stored procedures

Store and index JSON in MySQL 8, wrap queries in views, write stored procedures, and use REGEXP and TIMESTAMPDIFF in everyday SQL.

Apache Solr search server

Install Apache Solr as a service on Ubuntu or Debian, create a core, index documents and keep the admin UI private behind Nginx.

Install Redis or Valkey

Install Redis or its open fork Valkey, require a password through ACLs, keep it on localhost, choose RDB or AOF persistence and cap memory.

Install Memcached

Set up Memcached as a fast object cache, keep it on localhost with UDP off, size its memory and connect PHP or Python apps to it.

Apache Cassandra cluster

Install Apache Cassandra 5.0 on one node, then grow it into a small cluster over public IPs with internode TLS, passwords and a tight firewall.

Install Apache CouchDB

Install Apache CouchDB from the project repository as a single node, set an admin, keep port 5984 private and serve it over HTTPS.

InfluxDB for time series

Install InfluxDB from the official repository, run the first setup, write and query time series, scope tokens per app and feed it with Telegraf.

Install Elasticsearch

Install Elasticsearch from the official repository with security on by default, size the JVM heap, keep HTTP private and add snapshots.

Back up and restore MySQL and MariaDB

Dump and restore MySQL or MariaDB databases, pull one database out of a full dump, take physical backups with mariabackup or XtraBackup and automate it.

Back up and restore PostgreSQL

Back up PostgreSQL with pg_dump and pg_dumpall, restore with pg_restore, take base backups with pg_basebackup and add WAL archiving for point in time recovery.

MySQL users, roles and passwords

Create MySQL and MariaDB accounts with tight host parts, grant only what each app needs, group rights into roles and enforce password rules.

PostgreSQL roles and permissions

Design PostgreSQL roles for owners, apps and readers, set default privileges, store passwords as SCRAM and hash app passwords with pgcrypto.

Repair a crashed MySQL table

Find the damaged table, check it with CHECK TABLE or mysqlcheck, repair MyISAM and Aria tables, and recover InnoDB data with a forced-recovery dump.

PostgreSQL streaming replication

Stream WAL from a primary PostgreSQL server to a hot standby on a second VPS over TLS, with firewall rules that admit only the peer address.

MongoDB replica set

Join three MongoDB servers into a replica set over public IPs, with keyfile member auth, TLS on every connection and firewall rules for peers only.

PostGIS for location data

Add PostGIS to PostgreSQL, store points and shapes, index them with GiST, and answer distance, radius and nearest-neighbour questions in SQL.

Database insight with PgHero

Run the PgHero dashboard in Docker to spot slow queries, missing and unused indexes, bloat and connection pressure on your PostgreSQL server.

Couchbase Server

Install Couchbase Server Community Edition, set up a node from the command line, create a bucket and app user, and keep its many ports closed.

ArangoDB multi-model database

Install ArangoDB from its package repository, secure the root account, keep it on localhost, and work with documents and graphs in AQL.

Remote database access over SSH

Reach PostgreSQL, MySQL or MongoDB on your server from a laptop, a Python script or a GUI client through an SSH tunnel, with no database port open.