# Adminer + Multiple Database Types

> Lightweight database management in a single PHP file.

- Category: Database Stacks
- Difficulty: beginner
- Components: adminer, postgresql, mysql, mongodb
- Tags: adminer, database-management, php, lightweight
- Source: https://docker.recipes/databases/adminer-multi-db

## Overview

Adminer is a full-featured database management tool written entirely in a single PHP file, originally developed as a lightweight alternative to phpMyAdmin. Despite its minimal footprint of just 470KB, Adminer supports multiple database systems including MySQL, PostgreSQL, SQLite, MS SQL, Oracle, and MongoDB, making it an incredibly versatile tool for database administration. Its clean interface and zero-configuration approach have made it popular among developers who need quick database access without the complexity of larger administration tools.

This stack combines Adminer with PostgreSQL 15 and MySQL 8.0, creating a comprehensive database testing and development environment. The configuration allows you to switch between different database systems from a single web interface, making it ideal for applications that need to support multiple database backends or for comparing query performance across different engines. Adminer connects to each database server through the internal Docker network, providing secure access while exposing only the web interface to the host system.

Developers working on multi-database applications, database administrators managing heterogeneous environments, and teams evaluating different database technologies will find this stack particularly valuable. The combination eliminates the need to install separate management tools for each database type, while the containerized approach ensures consistent behavior regardless of the host operating system. Educational environments also benefit from this setup, as students can explore different SQL dialects and database features from a unified interface.

## Features

- Single PHP file deployment requiring only 470KB of disk space
- Native support for MySQL, PostgreSQL, SQLite, MS SQL, Oracle, and MongoDB
- Built-in SQL editor with syntax highlighting and query execution
- Database schema visualization and table structure editing
- CSV, SQL, and TSV export capabilities for data migration
- Plugin system supporting tables-filter and tinymce rich text editing
- Multiple visual themes including Nette, Pepa, and Hydra designs
- Cross-database query comparison and performance analysis tools

## Use cases

- Multi-database application development requiring PostgreSQL and MySQL compatibility testing
- Database migration projects comparing schema and data between different engines
- Educational environments teaching SQL across multiple database systems
- Development teams prototyping applications with different database backends
- Legacy system maintenance where multiple database types coexist
- Quick database troubleshooting and query debugging in containerized environments
- Small to medium businesses managing diverse database infrastructure from a single interface

## Prerequisites

- Docker Engine 20.10+ and Docker Compose 2.0+ installed
- Minimum 1GB RAM available for PostgreSQL and MySQL containers
- Port 8080 available on the host system for Adminer web interface
- Basic understanding of SQL and database concepts
- Environment variables configured for POSTGRES_USER, POSTGRES_PASSWORD, and MYSQL_ROOT_PASSWORD
- Familiarity with different SQL dialects if working across multiple database types

## docker-compose.yml

```yaml
services:
  adminer:
    image: adminer:latest
    environment:
      - ADMINER_DEFAULT_SERVER=postgres
      - ADMINER_DESIGN=nette
      - ADMINER_PLUGINS=tables-filter tinymce
    ports:
      - "8080:8080"
    networks:
      - adminer-network
    restart: unless-stopped

  postgres:
    image: postgres:15
    environment:
      - POSTGRES_USER=${POSTGRES_USER}
      - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
      - POSTGRES_DB=demo
    volumes:
      - postgres-data:/var/lib/postgresql/data
    networks:
      - adminer-network
    restart: unless-stopped

  mysql:
    image: mysql:8.0
    environment:
      - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
      - MYSQL_DATABASE=demo
    volumes:
      - mysql-data:/var/lib/mysql
    networks:
      - adminer-network
    restart: unless-stopped

volumes:
  postgres-data:
  mysql-data:

networks:
  adminer-network:
    driver: bridge
```

## .env

```bash
# Adminer
POSTGRES_USER=postgres
POSTGRES_PASSWORD=secure_postgres_password
MYSQL_ROOT_PASSWORD=secure_root_password
```

## Usage notes

- Adminer at http://localhost:8080
- Server: postgres or mysql
- Single file, lightweight
- Multiple themes available
- SQL export/import

## Troubleshooting

- Connection failed to database server: Verify the server name matches the Docker service name (postgres or mysql) in Adminer login
- MySQL authentication plugin error: Add --default-authentication-plugin=mysql_native_password to MySQL command or use mysql:5.7 image
- PostgreSQL connection refused: Ensure POSTGRES_USER and POSTGRES_PASSWORD environment variables are set and containers are fully started
- Adminer shows blank page: Check PHP memory limits and ensure port 8080 is not blocked by firewall
- Cannot import large SQL files: Increase PHP upload limits by mounting custom php.ini with higher upload_max_filesize and post_max_size
- Tables not visible in Adminer: Verify database user has proper SELECT privileges and the correct database/schema is selected

