Connect MySQL Docker container using Work Bench | SQL Yog and Other tool:
To connect MySQL Docker container using Workbench OR SQLyog require to run MySQL Docker container with Host Network, and detached (in the background)mode.
Explore more about Docker detached mode - https://severalnines.com/database-blog/mysql-docker-containers-understanding-basics
Following example run MySQL Docker container in detached mode, mounting volume - /mysql/mysql_data_1/data_1 outside contanier, with name - mysql_1, and MySQL server 8.0.18
#docker run -d --network host \
--volume=/mysql/mysql_2/data_1:/var/lib/mysql \
--name=mysql_1 mysql/mysql-server:8.0.18
But it has limitations:
Get MySQL root password:
# docker logs mysql_2 2>&1 | grep GENERATED
[Entrypoint] GENERATED ROOT PASSWORD: sIm7IPUmvUSODaKocvALYRiv6@S
Set New password for MySQL user root:
#docker exec -it mysql_1 mysql -uroot -p
mysql> alter user 'root'@'localhost' identified by 'new_password';
Access bash for MySQL Docker container:
#docker exec -it mysql_2 bash
Install text editor vi to change default authentication:
#yum install vi
Inspect MySQL Docker Container:
You will be able to see HostConfig, NetworkMode, Mounts, PortBindings and other items
#docker inspect mysql_1 | more
Ref.:
https://docs.docker.com/network/network-tutorial-host/
Explore:
Docker Network
7 layers (level) of OSI
Docker v/s Kubernetes
Weave v/s Calico
Weave
VXLAN
What is VXLAN
VXLAN White papers
To connect MySQL Docker container using Workbench OR SQLyog require to run MySQL Docker container with Host Network, and detached (in the background)mode.
Explore more about Docker detached mode - https://severalnines.com/database-blog/mysql-docker-containers-understanding-basics
Following example run MySQL Docker container in detached mode, mounting volume - /mysql/mysql_data_1/data_1 outside contanier, with name - mysql_1, and MySQL server 8.0.18
#docker run -d --network host \
--volume=/mysql/mysql_2/data_1:/var/lib/mysql \
--name=mysql_1 mysql/mysql-server:8.0.18
But it has limitations:
- You can have only one host network per machine host, means you can not create more.
- You can't link other container using --link
- Port mapping is not supported, means you can access MySQL at port 3306 only
- https://severalnines.com/database-blog/single-host-networking-mysql-containers-docker
- Docker Network and VXLAN
Get MySQL root password:
# docker logs mysql_2 2>&1 | grep GENERATED
[Entrypoint] GENERATED ROOT PASSWORD: sIm7IPUmvUSODaKocvALYRiv6@S
Set New password for MySQL user root:
#docker exec -it mysql_1 mysql -uroot -p
mysql> alter user 'root'@'localhost' identified by 'new_password';
Access bash for MySQL Docker container:
#docker exec -it mysql_2 bash
Install text editor vi to change default authentication:
#yum install vi
Inspect MySQL Docker Container:
You will be able to see HostConfig, NetworkMode, Mounts, PortBindings and other items
#docker inspect mysql_1 | more
Ref.:
https://docs.docker.com/network/network-tutorial-host/
Explore:
Docker Network
7 layers (level) of OSI
Docker v/s Kubernetes
Weave v/s Calico
Weave
VXLAN
What is VXLAN
VXLAN White papers
Connecting a MySQL Docker container using Workbench or SQL Yog is a game changer for database management! Discover the best practices with AmbitionHost to streamline your workflow.
ReplyDelete