How to create database MySQL with Docker

I’ll to show how to create an local database MySQL with Docker, in yours Windows. It is necessary has the last version Docker intalladed in your machine.

1st step: Dowload the MySQL image

Let’s download the latest MySQL image to the Docker hub, ty…

Image description

I’ll to show how to create an local database MySQL with Docker, in yours Windows. It is necessary has the last version Docker intalladed in your machine.

1st step: Dowload the MySQL image

Let’s download the latest MySQL image to the Docker hub, type the following command below:

docker pull mysql/mysql-server

2st step: Execute the container

Let´s execute the container for an image that we did download. At first, we don´t configure environment variables, at moment just execute the MySQL for default users without a password. Before executing the command, you can create a directory with the name mysql. Write the command below in your terminal.

Note: create only the directory C:/mysql for default, the MySQL to need has folder */var/lib/mysql, this directory the MySQL will save your database.*

Write the command below

docker ryn -e MYSQL_ALLOW_EMPTY_PASSWORD=yes -v C:/mysql/var/lib/mysql mysql

Image description

Image description

3st step: Getting the container’s IP

For discovery the container IP, write command docker container ls for verify the containers that running and copy the ID the container, using the command docker container inpect ID_CONTAINER.

Image description

4st step: Acess database from container

To access the database through the container, we need to go inside the container, so write the command below

docker exec -it ID_CONTAINER

Image description

Image description

Already. We have a datbase MySQL in container Docker. Now you can create your database and tables.

Image description

Image description

Conslusion

This is a sample example for you create database with docker. Of course this example I created the sample database, but you can configure user and password in your database.

Write for don´t forget.


Print Share Comment Cite Upload Translate
APA
Jéssica Nathany | Sciencx (2024-03-28T10:35:12+00:00) » How to create database MySQL with Docker. Retrieved from https://www.scien.cx/2022/01/22/how-to-create-database-mysql-with-docker/.
MLA
" » How to create database MySQL with Docker." Jéssica Nathany | Sciencx - Saturday January 22, 2022, https://www.scien.cx/2022/01/22/how-to-create-database-mysql-with-docker/
HARVARD
Jéssica Nathany | Sciencx Saturday January 22, 2022 » How to create database MySQL with Docker., viewed 2024-03-28T10:35:12+00:00,<https://www.scien.cx/2022/01/22/how-to-create-database-mysql-with-docker/>
VANCOUVER
Jéssica Nathany | Sciencx - » How to create database MySQL with Docker. [Internet]. [Accessed 2024-03-28T10:35:12+00:00]. Available from: https://www.scien.cx/2022/01/22/how-to-create-database-mysql-with-docker/
CHICAGO
" » How to create database MySQL with Docker." Jéssica Nathany | Sciencx - Accessed 2024-03-28T10:35:12+00:00. https://www.scien.cx/2022/01/22/how-to-create-database-mysql-with-docker/
IEEE
" » How to create database MySQL with Docker." Jéssica Nathany | Sciencx [Online]. Available: https://www.scien.cx/2022/01/22/how-to-create-database-mysql-with-docker/. [Accessed: 2024-03-28T10:35:12+00:00]
rf:citation
» How to create database MySQL with Docker | Jéssica Nathany | Sciencx | https://www.scien.cx/2022/01/22/how-to-create-database-mysql-with-docker/ | 2024-03-28T10:35:12+00:00
https://github.com/addpipe/simple-recorderjs-demo