A comprehensive Docker-based database management solution for development and testing environments. This project provides a unified way to manage MySQL, PostgreSQL, MongoDB, and Redis databases with their respective web management tools.
- Multi-Database Support: MySQL 8.0, PostgreSQL 16, MongoDB 7, Redis 7
- Web Management Tools: Adminer, pgAdmin, Mongo Express, Redis Insight
- Auto-Initialization: Databases and sample data are created automatically
- Automated Backups: Scheduled daily backups with configurable retention
- Local Storage: All data stored in organized local directories
- Professional Configuration: Optimized database configurations for development
- Backup & Restore: Built-in backup scripts for all databases
- Health Checks: Container health monitoring and dependencies
- Network Isolation: Secure internal network for database communication
# Clone or navigate to the project directory
cd /path/to/database
# Copy environment template
cp .env.example .env
# Start all services
./db-manager.sh start
# Check status
./db-manager.sh statusdatabase/
βββ .env # Environment variables configuration
βββ .env.example # Environment variables template
βββ docker-compose.yml # Docker Compose configuration
βββ db-manager.sh # Database management script
βββ README.md # This documentation
βββ mysql/ # MySQL related files
β βββ data/ # MySQL data storage
β βββ init/ # Initialization scripts
β βββ conf/ # Configuration files
β βββ backup/ # Backup files
βββ postgres/ # PostgreSQL related files
β βββ data/ # PostgreSQL data storage
β βββ init/ # Initialization scripts
β βββ backup/ # Backup files
βββ mongo/ # MongoDB related files
β βββ data/ # MongoDB data storage
β βββ init/ # Initialization scripts
β βββ backup/ # Backup files
βββ redis/ # Redis related files
β βββ data/ # Redis data storage
β βββ conf/ # Configuration files
β βββ backup/ # Backup files
βββ pgadmin/ # pgAdmin related files
β βββ data/ # pgAdmin configuration storage
βββ redisinsight/ # Redis Insight related files
βββ data/ # Redis Insight configuration storage
This database stack is perfect for:
- Development Environment: Local development with multiple database types
- Testing & QA: Consistent database setup across team members
- Prototyping: Quick setup for new projects requiring various databases
- Learning: Hands-on experience with different database technologies
- CI/CD Pipeline: Standardized database environment for testing
- Data Migration: Testing data migration scripts across different databases
- Host: localhost
- Port: 13306
- Root Password: Mysql!Root123
- Character Set: utf8mb4
The system supports automatic database and user creation based on the MYSQL_PROJECTS environment variable:
Configuration Format: database_name:username:password;
Single Project Example:
export MYSQL_PROJECTS="smart_sred:sred:123456;"Multiple Projects Example:
export MYSQL_PROJECTS="smart_sred:sred:123456;blog:blogger:blog123;shop:shopper:shop456;"Important Notes:
- Each project definition ends with a semicolon (
;) - Don't use colons (
:) in passwords - use special characters like@#_instead - Databases and users are created automatically when MySQL container starts
- Each user gets full privileges on their corresponding database
test_db: Usertest_user, Passwordtest123dev_db: Userdev_user, Passworddev123
- Host: localhost
- Port: 15432
- User: postgres
- Password: PgPass!123
postgres(default)test_dbdev_dbanalytics_db
- Host: localhost
- Port: 27017
- Admin User: admin
- Admin Password: MongoPass!123
test_db: Users, products, orders and other test datadev_db: Logs, sessions, cache and other development data
- Host: localhost
- Port: 16379
- Password: RedisPass!123
- URL: http://192.168.2.%:18080
- Description: Lightweight database management tool
- URL: http://192.168.2.%:18081
- Login Email: admin@local
- Password: PgPass!123
- URL: http://192.168.2.%:18082
- Username: admin
- Password: MongoPass!123
- URL: http://192.168.2.%:18083
- Description: Redis official visualization tool
The db-manager.sh script provides easy management of all database services:
# Start all services
./db-manager.sh start
# Check service status
./db-manager.sh status
# View logs
./db-manager.sh logs
# Enter database shell
./db-manager.sh shell mysql
./db-manager.sh shell postgres
./db-manager.sh shell mongo
./db-manager.sh shell redis
# Manual backup of all databases
./db-manager.sh backup
# Check backup status and recent backups
./db-manager.sh backup-status
# Stop services
./db-manager.sh stop- Scheduled Backups: Daily automated backups at 2 AM (configurable)
- Retention Policy: Configurable retention period (default 7 days)
- Compression: All backups are automatically compressed
- Individual & Full: Both full cluster and individual database backups
- Logging: Detailed backup logs with timestamps
- Health Monitoring: Backup service status monitoring
# In .env file
BACKUP_CRON=0 2 * * * # Daily at 2 AM
BACKUP_RETENTION_DAYS=7 # Keep for 7 days- MySQL:
mysql/backup/mysql_*_backup_*.sql.gz - PostgreSQL:
postgres/backup/postgres_*_backup_*.sql.gz - MongoDB:
mongo/backup/mongo_*_backup_*.tar.gz - Logs:
*/backup/backup_*.log
# Run immediate backup of all databases
./db-manager.sh backup
# Check backup service status and recent files
./db-manager.sh backup-status
# View backup logs
tail -f mysql/backup/backup_$(date +%Y-%m-%d).log
./db-manager.sh stopmysql -h localhost -P 13306 -u sred -p smart_sredpsql -h localhost -p 15432 -U postgres -d test_dbmongosh "mongodb://admin:MongoPass!123@localhost:27017"redis-cli -h localhost -p 16379 -a RedisPass!123Use these connection strings in your applications:
mysql://sred:123456@localhost:13306/smart_sred
postgresql://postgres:PgPass!123@localhost:15432/test_db
mongodb://admin:MongoPass!123@localhost:27017/test_db
redis://:RedisPass!123@localhost:16379
Copy .env.example to .env and customize the following settings:
- ALLOWED_NET: Network access restriction (default: 192.168.2.%)
- Database Ports: Custom port mappings for each database
- Passwords: Strong passwords for all database services
- Timezone: Database timezone settings
Each database includes initialization scripts that create:
- MySQL:
smart_sred,test_db, anddev_dbdatabases with users - PostgreSQL: Sample tables with UUID support and JSONB data
- MongoDB: User, product, and order collections with indexes
- Redis: Optimized configuration for development use
The initialization scripts create sample data for testing:
- Users: Admin and test user accounts
- Products: Sample e-commerce product data
- Orders: Test transaction records
- Analytics: Event tracking examples
- Change default passwords in production
- Restrict
ALLOWED_NETto your specific network - Use strong passwords for all services
- Consider enabling SSL/TLS for production use
Feel free to submit issues, fork the repository, and create pull requests for any improvements.
This project is open source and available under the MIT License.