How to run MySQL server inside a docker container using docker-compose.yml

  1. Create a folder named how_to_run_mysql_docker. All the required files and folders will be created in this folder.
  • Create a file named docker-compose.yml. Since this is a yml file, be careful about the indentation.
  • Create a folder named sql_init. In sql_init, create a file named tables.sql.
Folder structure.
New container is up.
  • Open MySQL Workbench. Click new connection button. You can give any connection name.
  • Port is 5005 (this port is defined in the docker-compose.yml file).
  • password is passworddb (this password is defined in the docker-compose.yml file).
MySQL connection.
  • Click OK. Now, you are connected to MySQL instance inside the docker container. You can see the results of the SQL scripts (sql_init/tables.sql).

--

--

--

software developer, software architect, software something.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Why We Backed GraphCMS

The only solution to this constant happiness dilemma is to picture yourself on the other side

Fun with tkinter: part 1

How learning Python changed my life?

APISIX, an API Gateway the Apache way

ALL ABOUT AWS AND CLOUD COMPUTING

HTML ELEMENTS

How Did I Become a Software Engineer?

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
rizahorasan

rizahorasan

software developer, software architect, software something.

More from Medium

Configuring the Webserver and Setting up Python environment on the Docker

GUI Applications in a Docker Container

How to create project RSA Cryptography with JAVA in 3 Steps: Step 1 Create User Interface

Useful Python Package