How to Set Up MySQL Database with Docker

preview_player
Показать описание

Docker is a product that allows developers to create containers, which are self-contained areas on their computer for running applications. They can be used for databases, which is great if you can't install it normally (e.g. you use a Mac).

This video shows you how to set up a MySQL database on Docker. It uses an existing MySQL image on the Docker Hub website. You can use many different versions of MySQL, not just the latest version.

You'll learn how to download and install Docker, find the right MySQL image, download the image, run it, and connect to it in MySQL Workbench. You can use any other IDE that works with MySQL if you prefer.

The connection details for this image mentioned in the video are below.

Host: localhost (or 127.0.0.1)
Port: 3306
Username: root
Password: whatever you specify in the "docker run" command

Timestamps:
00:00 In this video
00:05 High-level steps
00:28 Download Docker
01:22 Run Docker
02:07 Create Docker Hub account
02:41 Search for MySQL image on Docker Hub
03:12 Understand the docker run command
04:25 Adjust docker run command
05:28 Open Terminal and login to Docker
06:18 Download image using Docker Run
07:04 Check status using docker ps
07:33 Connect using MySQL Workbench
07:58 Enter connection details
08:54 Run simple query
Рекомендации по теме
Комментарии
Автор

If every tutorial were as simple as this one, the world would be a better place. :)

talios
Автор

I was trying to learn how to set up a SQL database on my homelab as a beginner for like over a week, and I for the life of me couldn't figure out why it wasn't working. You really saved my butt with this video, thank you!

MichaelDude
Автор

After spending HOURS trying to get this to work, this video is EXACTLY what I needed. Thank you so much!

brycenasay
Автор

two years later and still very helpful. thank you sir.

pouriapmd
Автор

Great overview on how to do with Docker, but I'm not sure why anyone would want to do it this long-winded and complex way. On Linux you can install mySQL with a single line on the terminal and for Mac and Windows you can use MAMP or XAMPP which can be set up with a few simple clicks and have a GUI for easy management. I'm guessing Docker could allow different configurations?

RogerHolden
Автор

Just two remarks. Why setting up a docker account to pull the image from docker hub? This is not necessary. Second one what about persistence? If you create tables etc, and fill them all the work is gone as soon as you stop the container. Why not adding a simple -v to the docker run command to set up a db file on the host?

tarikb.
Автор

When i test the connection, i get an error message "Access denied for user 'root'@'localhost' (using password: YES)" . Any idea what might be causing that ? The container was made just fine and is running.

heroman
Автор

Hi Sir, I want to ask a question when I try to run this command: "docker run --name mysqlreview -e MYSQL_ROOT_PASSWORD=mypss -d -p 3312:3306 mysql:latest", If I confuse the container port (3306) with the host port (3312), and instead of 3312:3306 I type 3306:3312, besides not being able to run MySQL, I'm wondering if there are any risks involved?
Thank you!

Nam-kh
Автор

Not able to connect to MySQL using docker credentials, how can I see database in my local MySQL's db?

MelodySongsPlace
Автор

which version of workbench you have used... because my workbench version is 8.0.34 and its says that it may not work properly
Good explanation by the way

vpms
Автор

So couple of things I noticed, --name indicates the name of the container, not the image. So we can refer to the container by "some-mysql". "-p" is short for publish that represents mapping between the ports in local machine and containers, it does not mean just ports.

skh
Автор

my mysql workbench is running 3307 port what should i do, when i am entering 3306 port it is showing password denied error please help

krishnasagar
Автор

What a tutorial, detailed yet simple plus calming voice

kushagrakasliwal
Автор

This tutorial is really helpful and instructive for a beginner like me. Much appreciated of your work!

manhkhang
Автор

Where is my image?, i need the dockerfile to upload to my github and i don't know where it is, please help

rivertorres
Автор

I did but I changed the port to 3307. How can I get the DB_Hostname cause I need to connect it to my laravel app. Hope you can help. Thank you.

vensonestrope
Автор

Thank you so much 😊 I appreciate your work! I wouldn’t be able to manage it on my own

santrolli
Автор

for me the whole video was helpful, im currently trying to learn how to use corteza and was trying to figure out how to connect a database, turns out you connect to docker and it kind of just connects on its own somehow.

westcoastwarriorsarchive
Автор

When I run SELECT NOW() it shuts off the Mysql Workbench. I am using Docker on a Mac.

christopherjspiteri
Автор

latest: Pulling from library/mysql
docker: no matching manifest for linux/arm64/v8 in the manifest list entries.
See 'docker run --help'. getting this error

swapnilkumar