MySQL Docker Container Exercise

You can up and run MySQL Docker container in your local machine and later connect from mysql CLI to query your database.

Run the following command in your terminal to up and run a MySQL Database Docker container.

docker run -p 3306:3306 --name some-mysql -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql:latest

Run the below code in the terminal to connect to running container.

docker exec -it some-mysql bash

Run the below code in the terminal after connecting to container.

mysql -h 127.0.0.1 -P 3306 -u root -p

Then you need to enter password, we need to enter my-secret-pw

Follow the following link for more details

https://hub.docker.com/_/mysql

There are more practice in this video 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *