Run MySQL with Adminer using Docker (No XAMPP or LAMP Required)
Teqani Blogs
Writer at Teqani
For developers needing a quick MySQL database setup, Docker provides a lightweight alternative to XAMPP or LAMP. This method ensures isolation and portability, streamlining your development workflow. This tutorial guides you through setting up MySQL and Adminer with Docker, eliminating the need for bulky tools.
Step 1: Create a Temporary Folder
Begin by creating a directory for your Docker setup. This folder will house your docker-compose.yml
file and all data generated during MySQL usage.
mkdir mysql-docker-setup
cd mysql-docker-setup
Step 2: Add Docker Compose File
Within the folder, create a docker-compose.yml
file with the following content:
version: "3.8"
services:
mysql:
image: mysql:8.0
container_name: mysql8
restart: always
environment:
MYSQL_ROOT_PASSWORD: password
ports:
- "3306:3306"
volumes:
- mysql_data:/var/lib/mysql
adminer:
image: adminer
container_name: adminer
restart: always
ports:
- "8080:8080"
volumes:
mysql_data:
This configuration runs a MySQL 8.0 container with a root password and Adminer, a lightweight web-based database management tool.
Step 3: Run the Containers
Start the containers by executing:
docker-compose up -d
Verify they are running with:
docker ps
Step 4: Access Adminer
Open your browser and navigate to http://localhost:8080
. Use the following credentials:
- System: MySQL
- Server: mysql
- Username: root
- Password: password
You now have a fully functional database management tool.
Step 5: Connect Locally
Connect directly to the MySQL instance from your local tools like DBeaver or MySQL Workbench. The default ports are 3306 for MySQL and 8080 for Adminer. Adjust the docker-compose.yml
file if necessary.
ports:
- "3307:3306"
- "9090:8080"
Connect using:
MySQL: localhost:3307
Adminer: http://localhost:9090
Why This Is Better Than XAMPP or LAMP
- Lightweight: Only MySQL and Adminer.
- Portable: Works on any system with Docker.
- Isolated: No interference with your system's MySQL.
- Reusable: Multiple setups for different projects.
Using Docker for databases simplifies and streamlines your workflow, providing a more reliable and cleaner development experience.
All blogs are certified by our company and reviewed by our specialists
Issue Number: #d2e900ba-75cc-4dff-a013-dd0b08bc3f63