Databases core
Guides for PostgreSQL, MySQL, and MariaDB: install, users, backups, restore, tuning, replication, connection pooling, migrations, and security. Use these when you run or operate relational databases.
- easy 18
- medium 10
- hard 2
Easy
- Database backup verification checklist
Use this checklist to verify database backups are configured, running, and restorable. Covers backup schedule, retention, restore test, and access control. Run periodically and before major changes or go-live.
- MySQL and MariaDB backup basics (mysqldump and physical)
Back up MySQL or MariaDB with mysqldump for logical backups or use filesystem snapshots with FLUSH TABLES WITH READ LOCK for consistent physical backup. Use this when setting up backup jobs or when you need to restore a database.
- How to create a MySQL or MariaDB user and grant permissions
Create a MySQL user with CREATE USER and grant privileges with GRANT on databases, tables, or global. Restrict by host (e.g. 'app'@'10.0.0.%'). Use this when onboarding an application or implementing least privilege access to MySQL or MariaDB.
- How to install MySQL or MariaDB on Linux
Install MySQL 8 or MariaDB on Debian, Ubuntu, or RHEL using the official or distro repository. Secure the installation with mysql_secure_installation; create a database and user. Use this when setting up a new database server or when you need MySQL-compatible storage.
- How to restore MySQL or MariaDB from backup
Restore a MySQL or MariaDB database from a mysqldump file using the mysql client. Create the database first if needed. Use this when recovering from a failure or when cloning a database from a logical backup.
- PostgreSQL backup basics (pg_dump and pg_basebackup)
Back up PostgreSQL with pg_dump for logical backups (single DB or full cluster) or pg_basebackup for physical backups. Use WAL archiving for point-in-time recovery. Use this when setting up backup jobs or when you need to restore a database or cluster.
- PostgreSQL config basics (postgresql.conf and pg_hba.conf)
Configure PostgreSQL via postgresql.conf (memory, connections, WAL) and pg_hba.conf (who can connect and how). Reload or restart after changes. Use this when tuning performance, enabling remote access, or locking down authentication.
- How to create a PostgreSQL user and grant permissions
Create a PostgreSQL role (user) with CREATE USER or CREATE ROLE; grant privileges with GRANT on databases, schemas, and tables. Use LOGIN for interactive users and NOLOGIN for app roles. Use this when onboarding a new user or service account or when implementing least privilege.
- How to install PostgreSQL on Linux
Install PostgreSQL on Debian, Ubuntu, or RHEL using the official or distro package repository. Configure the data directory, init the cluster, and start the server so you can create databases and users. Use this when setting up a new database server or when you need a specific PostgreSQL version.
- How to restore a PostgreSQL database
Restore from a pg_dump custom-format file with pg_restore, or from a plain SQL dump with psql. Drop or create the target database first if replacing; restore globals with psql if you have pg_dumpall output. Use this when recovering from a failure or when cloning a database.
- Pre-production database checklist
Use this checklist before putting a database into production: backups, users, security, config, monitoring, and restore test. Ensures nothing is missed and the database is ready for production load and recovery.
- Database security basics
Harden database access: least-privilege users, network restriction, encryption in transit and at rest, and audit logging. Use this when deploying a new database or when reviewing security for an existing PostgreSQL or MySQL instance.
- Database backup retention policy
Define how long to keep database backups based on RTO, RPO, and compliance. Use full plus incremental or differential; test restore regularly. Use this when setting or reviewing backup retention.
- Secure database connection strings
Store database connection strings in environment variables or a secrets manager; never commit them to source control. Use least-privilege users and SSL. Use this when deploying apps that connect to a database.
- MySQL or MariaDB config basics
MySQL and MariaDB use my.cnf or my.ini for configuration. Key settings include datadir, port, bind-address, max_connections, and buffer pool. Use this when tuning or securing the server.
- PostgreSQL logging basics
Configure PostgreSQL logging with log_destination, log_directory, and log_filename. Use log_min_duration_statement for slow queries and log_connections for audit. Use this when debugging or meeting audit requirements.
- PostgreSQL VACUUM basics
VACUUM reclaims dead tuple space and updates visibility for the planner. Run VACUUM ANALYZE after bulk changes. Rely on autovacuum; tune if needed. Use this when you see bloat or stale stats.
- When to use read replicas
Use read replicas when read load exceeds primary capacity or you need geographic distribution. Replicas add lag and eventual consistency. Use this when deciding whether to add replication for scaling or HA.
Medium
- Database connection pooling basics
Use a connection pool (PgBouncer, ProxySQL, or application-level) so many application threads share a smaller number of database connections. Reduces connection churn and stays under max_connections. Use this when you have many app instances or high concurrency and hit connection limits.
- Database disaster recovery basics
Define RPO and RTO for databases; use backups and optionally replication to meet them. Restore from backup or fail over to a replica; document and test the procedure. Use this when planning or executing database recovery after a failure or data loss.
- Database migrations basics (schema changes safely)
Apply schema and data changes in versioned, reversible steps using migration scripts or tools (e.g. Flyway, Liquibase, or custom SQL). Test on staging first; backup before production migration. Use this when introducing or evolving schema in a way that is auditable and rollback-safe.
- PostgreSQL replication basics (streaming replica)
Set up a streaming replica for high availability or read scaling. Configure the primary for replication (wal_level, pg_hba); use pg_basebackup to clone; add primary_conninfo and recovery target on the replica. Use this when you need a standby or read replica.
- PostgreSQL slow query basics
Find and fix slow PostgreSQL queries using log_min_duration_statement and pg_stat_statements. Use EXPLAIN ANALYZE to see the plan and add indexes or rewrite queries. Use this when the database is slow or when optimizing after enabling query logging.
- PostgreSQL tuning basics (memory, connections, checkpoints)
Tune PostgreSQL for your workload by setting shared_buffers, work_mem, effective_cache_size, and checkpoint-related parameters. Use EXPLAIN ANALYZE to find slow queries; add indexes as needed. Use this when the database is slow or when sizing a new server.
- MySQL or MariaDB slow query basics
Enable slow query log and use EXPLAIN to fix slow MySQL queries. Add indexes on WHERE and JOIN columns. Use this when the database is slow.
- MySQL or MariaDB SSL/TLS basics
Enable SSL for MySQL or MariaDB with ssl_cert, ssl_key, and ssl_ca in my.cnf. Require SSL for users with REQUIRE SSL. Use this for encrypted connections and compliance.
- MySQL or MariaDB tuning basics
Tune MySQL or MariaDB with innodb_buffer_pool_size, query cache (if available), connection limits, and slow query log. Use this when improving performance or after measuring bottlenecks.
- PostgreSQL SSL/TLS basics
Enable SSL for PostgreSQL with ssl = on and server cert and key in postgresql.conf. Clients use sslmode=require or verify-full. Use this for encrypted connections and compliance.
Hard
- MySQL or MariaDB replication basics
Set up MySQL replication with binary logging on the primary and CHANGE REPLICATION SOURCE on the replica. Use for read scaling or HA. Use this when you need a replica for reads or failover.
- PostgreSQL upgrade basics
Upgrade PostgreSQL by using pg_dump and pg_restore (logical) or pg_upgrade (in-place). Logical is safer and works across major versions; pg_upgrade is faster but same major. Use this when moving to a new major version.