Comprehensive Guide to Deploying MySQL with Docker

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] foreign [Music] Khan and today I'm going to be working on another Docker project and that is basically deploying the mySQL database into Docker container and I will also be working on the Persistence of data so what do I mean by this so basically it will work uh like let's say if you created one Docker container and if you delete the docker container the mySQL database that is that was present in the docker container will still be working even if the docker container is deleted all right so even if the docker container is deleted the myscript database will still be working in another container also so this is how it will work and I will do this with the help of Docker volume so now let's write first of all Docker images so as you can see here that there is no image by the name of MySQL and after that if I show you the docker PS you will see that there is no container also so the first thing that I'm going to do is to write the docker pool MySQL so this is uh this will pull the MySQL image from the docker Hub so let's press enter on this so it could take me some time to pull the image so some of the files are already exist so let's clear this and now this time if I write Docker images you will see that the MySQL repository or the image is present so let's clear this and after that let's write Docker volume create mySQL database so MySQL data so basically it will create this MySQL data container and that will uh that will basically still be working this will create the MySQL data database that will still be working even if the docker container is deleted so let's press enter on this so now the MySQL data is created after that if I show you the docker PS you can see that the docker container is not present here currently so let's write Docker run and this time it will be the name of the docker container like the myscale container so even if this MySQL container is deleted the MySQL data will still be working as I have shown you that the MySQL data that I created with the help of Docker volume that Docker volume uh that Docker my scheme data will still be working even if the MySQL container is deleted all right so I will show you uh this is the um MySQL container me and a continual name and after that let's write e for what you can say uh giving the root password like MySQL MySQL root password and after that let's write the password so password could be anything like the MySQL password that you have but I'm just showing it for the example and after that let's write what you can say um V so we will basically uh what it will do it will add MySQL data and like variable a lib and MySQL so it will Mount the MySQL data that I created with the help of Docker module it will Mount that data into this repository into this directory sorry all right so it will Mount this MySQL data into this directory and after that it will move this in the run this in the detached mode like MySQL you just like this and uh yeah this is how it will work so let me just check whether it contains any kind of error so no error so first of all I need to give this uh as a real password and after that I will I will get back to you because I don't want uh you to see my SQL password right so let's press and write it and I'll get back to you so now I have run the docker container if I show you like Docker PS you will see that this is the container that is now created MySQL container let's clear this and after that let's write Docker uh what you can say execute that container and it interactive environment and MySQL container and after that MySQL root P this is how it will work so let's press enter on this now I need to enter the MySQL password so let's enter the password Here now I'll present in the mySQL database so let's write what you can say first of all show databases you can see that these are the databases that that is currently present that are currently present so I need to delete this another database like the drop database another and after that if I clear this Android show databases again you will see that another database is not present now I I will create another database let's say create database by the name of what you can say um Docker MySQL like this all right so it is the name of the database just a random name so let's create this and now let's write Docker did sorry show databases you will see that the docker mySQL database is present here so now let's exit this and after that let's delete the MySQL container now I am going to show you that how the mysq database will still be present even if the docker container is deleted so let's write Docker stock my SQL container so sorry uh sorry MySQL Docker stop MySQL like this container so yeah this is how it should work so the docker container this is stopped now and after that let's write Docker RM uh instead of writing stock I will write RM so this will uh remove the MySQL container also like docker PS you will see that there is no container present here all right so now the container is deleted and similarly the mySQL database is also deleted with it if I show you in it let's say because uh show it to you like this show databases you can see there's no the database is present here by the name of docker mysq so now what I will do I will run the same command like Docker run [Music] and this time it would be name let's say and the name is going to be another container previously it was MySQL container but now I am going to make it like another MySQL continue like this all right so after that let's write e for what you can say giving the root password so MySQL root password and just for the example purpose I'm writing any random thing and after that we what you can say that we is going to be like MySQL data so the MySQL data will be the same as you can see here that this is the MySQL data that I previously created and this is the docker volume that is already stored so this will be present every in every container if you want to all right so let's write after that email skill all right and after that let's write D in the detached mode it will run like MySQL latest all right so let me just check it another MySQL container this is a password this is the V that will basically transfer this MySQL data or Mount this MySQL data into this default directory that is this one it will Mount this my screen data into the default directory of the MySQL and it will run it into the detached mode and after that let me just give it a password and I will get back to you now I have run this and let's see if I write Docker PS you will see that another MySQL container is created and this is working fine now after that let's write Docker exec it interactive environment and after that let's write another from my SQL container MySQL you would be so it is asking for a password so I will give the myscale password now I'm present in the MySQL password and in another container not in the previous container that I removed it and I stopped it but this is another MySQL container and this time if I write show databases you will see that the docker MySQL is still present even if the container was deleted the previous container was deleted but with this new container the docker mySQL database is still present so it means that even if you delete the container the docker the database will still be present so this is how the persistent data will work all right so this was the thing that I was talking about all right so now let's write Docker PS I need to delete this also so I will write Docker PS first of all this is the sorry Docker PS This is the docker that I'm going to delete a Docker container so let's copy this Docker stop and once it is stopped I will write down car RM and uh this is going to be removed and after that if I create another container the same Docker mySQL database will be present in it right and this time if I write Docker image image images you will see that the MySQL image is present so I need to delete this also RMI my SQL like this all right so so now this image is not surprised are deleted right so Docker images you can see that the docker image is not present so yeah this is how it will work so I hope you understood and like this video so if you liked it then make sure to subscribe to my channel and if you have any questions then ask those questions in the comment section below I'll be happy to answer all of them so till then goodbye [Music]
Info
Channel: Code Roamer
Views: 89
Rating: undefined out of 5
Keywords: devops, projects, project, ibilalkayy, freecodecamp, technology, golang, software, freecodecamp.org, coding, programming, tech, languages, tutorial, course, tasks, traversy media, git, mysql, mongodb, mentorship, cobra library, command line interface, application, scholarship, call for proposal, promotion, twitter spaces, events, monokle, kubeshop, kubernetes, business, startup, session, motivation, books, bootstrap, investor, investment
Id: fMz3CkvCPf4
Channel Id: undefined
Length: 11min 27sec (687 seconds)
Published: Fri Aug 11 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.