How to Connect to MySQL in Docker from Localhost | Docker-Compose & HeidiSQL

Опубликовано: 17 Июль 2026
на канале: Shaloshvili Dev
145
5

Learn how to connect to a MySQL database running in Docker from your localhost! 🚀 In this tutorial, I'll show you how to:

✅ Set up a MySQL container using docker-compose and standalone Docker commands
✅ Configure volume mounting for persistent data storage
✅ Connect from localhost using any MySQL client (I'm using HeidiSQL)
✅ Troubleshoot common connection issues

Whether you're a beginner or an experienced developer, this guide will help you set up a MySQL database in Docker with ease. Don't forget to like, subscribe, and hit the notification bell for more programming tutorials! 🔥

📌 Note for the viewer

→ 1. docker-compose / mysql

mysql_helper:
container_name: mysql_helper
image: mysql
volumes:
./mysql-data:/var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD=root
networks:
networks_helper
ports:
'127.0.0.1:3310:3306'

→ 2. The Docker command
docker run --name docker_sql_gate -e MYSQL_ROOT_PASSWORD=root -d -p 127.0.0.1:3310:3306 -v "$(pwd)/mysql-data:/var/lib/mysql" mysql



#Docker #MySQL #DockerCompose #Database #DevOps #heidisql