# DbGate Universal Database Manager

> Cross-platform database manager supporting multiple database engines.

- Category: Database Stacks
- Difficulty: beginner
- Components: dbgate, postgresql, mysql, mongodb
- Tags: dbgate, database, gui, manager, multi-database
- Source: https://docker.recipes/databases/dbgate-multidb

## Overview

DbGate is an open-source universal database management tool that provides a web-based interface for working with multiple database engines simultaneously. Originally developed as a cross-platform alternative to platform-specific database tools, DbGate offers a unified experience for managing PostgreSQL, MySQL, MongoDB, SQLite, and other databases through a single interface. Its browser-based architecture makes it particularly valuable for teams working across different operating systems and environments.

This multi-database stack combines DbGate's universal management capabilities with three of the most popular database engines: PostgreSQL for advanced relational operations with JSON support, MySQL for high-performance web applications, and MongoDB for flexible document storage. The configuration creates an isolated environment where DbGate can connect to all three databases simultaneously, enabling side-by-side comparisons, cross-database queries, and unified data management workflows.

This setup is ideal for full-stack developers working on polyglot persistence architectures, database administrators managing heterogeneous environments, and development teams evaluating different database technologies. The combination provides hands-on experience with relational and document databases while offering the convenience of managing everything through DbGate's intuitive web interface, complete with syntax highlighting, query building, and data visualization tools.

## Features

- Universal database connectivity supporting PostgreSQL, MySQL, and MongoDB through a single web interface
- Advanced SQL editor with syntax highlighting, autocomplete, and query execution plans
- Visual query builder for constructing complex queries without writing SQL
- Data import/export capabilities with support for CSV, JSON, and SQL formats across all database types
- Schema comparison tools for identifying differences between database structures
- Real-time query result visualization with charts and graphs
- Database structure explorer with table relationships and index information
- Cross-database query execution for comparing data between PostgreSQL, MySQL, and MongoDB

## Use cases

- Full-stack development teams prototyping applications with different database backends
- Database administrators migrating data between PostgreSQL, MySQL, and MongoDB systems
- Educational environments teaching database concepts across multiple database paradigms
- Startup teams evaluating which database technology best fits their application requirements
- Development agencies managing client projects with diverse database requirements
- Data analysts performing cross-database comparisons and reporting
- Quality assurance teams validating data consistency across multiple database systems

## Prerequisites

- Minimum 4GB RAM to support all three database engines plus DbGate interface
- Docker and Docker Compose installed with at least 10GB available disk space
- Port 3000 available for DbGate web interface access
- Basic understanding of SQL for PostgreSQL and MySQL operations
- Familiarity with JSON document structure for MongoDB operations
- Environment variables configured: POSTGRES_PASSWORD, MYSQL_PASSWORD, and MONGO_PASSWORD

## docker-compose.yml

```yaml
services:
  dbgate:
    image: dbgate/dbgate:latest
    ports:
      - "3000:3000"
    volumes:
      - dbgate_data:/root/.dbgate
    environment:
      - CONNECTIONS=postgres,mysql,mongodb
    networks:
      - dbgate_net

  postgres:
    image: postgres:15-alpine
    environment:
      - POSTGRES_USER=admin
      - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
      - POSTGRES_DB=testdb
    volumes:
      - postgres_data:/var/lib/postgresql/data
    networks:
      - dbgate_net

  mysql:
    image: mysql:8.0
    environment:
      - MYSQL_ROOT_PASSWORD=${MYSQL_PASSWORD}
      - MYSQL_DATABASE=testdb
    volumes:
      - mysql_data:/var/lib/mysql
    networks:
      - dbgate_net

  mongodb:
    image: mongo:6
    environment:
      - MONGO_INITDB_ROOT_USERNAME=admin
      - MONGO_INITDB_ROOT_PASSWORD=${MONGO_PASSWORD}
    volumes:
      - mongo_data:/data/db
    networks:
      - dbgate_net

volumes:
  dbgate_data:
  postgres_data:
  mysql_data:
  mongo_data:

networks:
  dbgate_net:
```

## .env

```bash
# DbGate
POSTGRES_PASSWORD=secure_postgres_password
MYSQL_PASSWORD=secure_mysql_password
MONGO_PASSWORD=secure_mongo_password

# DbGate at http://localhost:3000
```

## Usage notes

- DbGate at http://localhost:3000
- Connect to multiple databases
- Query editor with autocomplete
- Export/import data
- Dark theme available

## Troubleshooting

- DbGate shows 'Connection refused' errors: Ensure all database containers are fully started by checking docker-compose logs for each service
- PostgreSQL connection fails with authentication error: Verify POSTGRES_PASSWORD environment variable matches the password configured in DbGate connection settings
- MySQL container exits with 'mysqld: ready for connections' then stops: Increase Docker memory allocation to at least 2GB for MySQL 8.0 operations
- MongoDB connection shows 'Authentication failed': Use 'admin' as both username and authentication database when configuring the MongoDB connection in DbGate
- DbGate interface loads but databases appear empty: Check network connectivity by ensuring all services are on the dbgate_net network and can resolve container names
- Query timeouts on large datasets: Increase DbGate query timeout settings in the application preferences and ensure adequate memory allocation for database containers

