MySQL + phpMyAdmin
MySQL database server with phpMyAdmin web interface for visual database management and administration.
Overview
MySQL is the world's most widely deployed open-source relational database management system, powering millions of web applications from small WordPress sites to massive enterprise platforms. Originally developed by MySQL AB in 1995, it has become the backbone of the modern web stack, particularly in LAMP (Linux, Apache, MySQL, PHP) environments. Its reputation for speed, reliability, and ease of use has made it the go-to choice for developers who need robust data storage without the complexity of enterprise database systems.
This stack combines MySQL 8.0 with phpMyAdmin, creating a complete database solution with visual management capabilities. phpMyAdmin provides a web-based interface that transforms MySQL's command-line administration into an intuitive graphical experience, allowing users to create databases, manage tables, execute queries, and handle user permissions through a browser. The two containers communicate over a dedicated Docker network, with phpMyAdmin automatically connecting to the MySQL instance without additional configuration.
This combination is perfect for web developers, small to medium businesses, and anyone who needs MySQL database functionality with easy visual management. Whether you're running WordPress sites, developing PHP applications, or need a development database with administrative tools, this stack provides immediate productivity. The setup is particularly valuable for teams where not all members are comfortable with command-line database administration, as phpMyAdmin makes complex database operations accessible through its web interface.
Key Features
- MySQL 8.0 with InnoDB storage engine providing ACID compliance and foreign key constraints
- phpMyAdmin web interface with full MySQL administration, SQL editor, and query bookmarks
- JSON data type support with native indexing and path-based queries in MySQL 8.0
- Import/export functionality supporting CSV, SQL, XML, and other database formats
- Visual database designer in phpMyAdmin for creating relationships and ER diagrams
- MySQL Group Replication support for high availability configurations
- Full-text search capabilities with natural language and boolean mode searching
- User privilege management through phpMyAdmin's intuitive interface
Common Use Cases
- 1WordPress and PHP application development with visual database management
- 2Small to medium business applications requiring relational data storage
- 3Web hosting environments where clients need database access without shell access
- 4Development and testing environments for MySQL-based applications
- 5Educational settings for teaching SQL and database administration concepts
- 6Legacy application migration where phpMyAdmin provides familiar MySQL tooling
- 7Multi-tenant applications where different teams need database access through web interface
Prerequisites
- Minimum 512MB RAM available (256MB for MySQL + 128MB for phpMyAdmin)
- Docker and Docker Compose installed on the host system
- Ports 3306 and 8080 available on the host machine
- Basic understanding of SQL and relational database concepts
- Environment file (.env) with MySQL credentials configured
For development & testing. Review security settings, change default credentials, and test thoroughly before production use. See Terms
docker-compose.yml
docker-compose.yml
1services: 2 mysql: 3 image: mysql:8.04 container_name: mysql5 restart: unless-stopped6 environment: 7 MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}8 MYSQL_DATABASE: ${MYSQL_DATABASE}9 MYSQL_USER: ${MYSQL_USER}10 MYSQL_PASSWORD: ${MYSQL_PASSWORD}11 volumes: 12 - mysql_data:/var/lib/mysql13 ports: 14 - "3306:3306"15 networks: 16 - mysql-network1718 phpmyadmin: 19 image: phpmyadmin:latest20 container_name: phpmyadmin21 restart: unless-stopped22 environment: 23 PMA_HOST: mysql24 PMA_PORT: 330625 ports: 26 - "8080:80"27 depends_on: 28 - mysql29 networks: 30 - mysql-network3132volumes: 33 mysql_data: 3435networks: 36 mysql-network: 37 driver: bridge.env Template
.env
1MYSQL_ROOT_PASSWORD=rootpassword2MYSQL_DATABASE=myapp3MYSQL_USER=appuser4MYSQL_PASSWORD=changemeUsage Notes
- 1Docs: https://dev.mysql.com/doc/ | phpMyAdmin: https://www.phpmyadmin.net/docs/
- 2Access phpMyAdmin at http://localhost:8080
- 3Login with root/MYSQL_ROOT_PASSWORD or MYSQL_USER/MYSQL_PASSWORD
- 4Backup: docker exec mysql mysqldump -u root -p --all-databases > backup.sql
- 5For production, set MYSQL_ROOT_HOST to restrict root access
- 6Data persisted in mysql_data volume - backup /var/lib/mysql regularly
Individual Services(2 services)
Copy individual services to mix and match with your existing compose files.
mysql
mysql:
image: mysql:8.0
container_name: mysql
restart: unless-stopped
environment:
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
MYSQL_DATABASE: ${MYSQL_DATABASE}
MYSQL_USER: ${MYSQL_USER}
MYSQL_PASSWORD: ${MYSQL_PASSWORD}
volumes:
- mysql_data:/var/lib/mysql
ports:
- "3306:3306"
networks:
- mysql-network
phpmyadmin
phpmyadmin:
image: phpmyadmin:latest
container_name: phpmyadmin
restart: unless-stopped
environment:
PMA_HOST: mysql
PMA_PORT: 3306
ports:
- "8080:80"
depends_on:
- mysql
networks:
- mysql-network
Quick Start
terminal
1# 1. Create the compose file2cat > docker-compose.yml << 'EOF'3services:4 mysql:5 image: mysql:8.06 container_name: mysql7 restart: unless-stopped8 environment:9 MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}10 MYSQL_DATABASE: ${MYSQL_DATABASE}11 MYSQL_USER: ${MYSQL_USER}12 MYSQL_PASSWORD: ${MYSQL_PASSWORD}13 volumes:14 - mysql_data:/var/lib/mysql15 ports:16 - "3306:3306"17 networks:18 - mysql-network1920 phpmyadmin:21 image: phpmyadmin:latest22 container_name: phpmyadmin23 restart: unless-stopped24 environment:25 PMA_HOST: mysql26 PMA_PORT: 330627 ports:28 - "8080:80"29 depends_on:30 - mysql31 networks:32 - mysql-network3334volumes:35 mysql_data:3637networks:38 mysql-network:39 driver: bridge40EOF4142# 2. Create the .env file43cat > .env << 'EOF'44MYSQL_ROOT_PASSWORD=rootpassword45MYSQL_DATABASE=myapp46MYSQL_USER=appuser47MYSQL_PASSWORD=changeme48EOF4950# 3. Start the services51docker compose up -d5253# 4. View logs54docker compose logs -fOne-Liner
Run this command to download and set up the recipe in one step:
terminal
1curl -fsSL https://docker.recipes/api/recipes/mysql-phpmyadmin/run | bashTroubleshooting
- Connection refused on port 3306: Check if MySQL container started successfully and MYSQL_ROOT_PASSWORD is set in environment variables
- phpMyAdmin shows 'mysqli_real_connect(): (HY000/2002)': Ensure both containers are on the same network and MySQL container is fully initialized before phpMyAdmin starts
- Access denied for user 'root'@'%': Verify MYSQL_ROOT_PASSWORD matches between containers, or use MYSQL_USER/MYSQL_PASSWORD for non-root access
- Import file size exceeded in phpMyAdmin: Increase PHP upload limits by mounting custom PHP configuration or use mysql command line for large imports
- MySQL data lost after container restart: Confirm mysql_data volume is properly mounted and not using anonymous volumes
Community Notes
Loading...
Loading notes...
Download Recipe Kit
Get all files in a ready-to-deploy package
Includes docker-compose.yml, .env template, README, and license
Ad Space
Shortcuts: C CopyF FavoriteD Download