Python MySQL Database Connectivity - MySQL Connector | 2022 Complete Guide

Python MySQL Database Connectivity - MySQL Connector | 2022 Complete Guide


Python MySQL Database Connectivity - MySQL Connector | 2022 Complete Guide

In this video, learn to connect Python with MySQL database. We will install the MySQL connector, after installing Python and MySQL.

MySQL Tutorial for Beginners
   • Learn MySQL in 3 Hours with 45 lesson…  

#PythonMySQL #MySQLConnector #AmitThinks

► Top Online Courses From Amit Thinks
MySQL Tutorial for Beginners: ⭐️    • Learn MySQL in 3 Hours with 45 lesson…  
MongoDB Tutorial for Beginners: ⭐️    • MongoDB Tutorial for Beginners | Full…  
Bootstrap 4 Tutorial: ⭐️    • วิดีโอ  
Eclipse Programming Tutorial: ⭐️    • Learn Eclipse in 1 Hour with 30 lesso…  

► Follow
My Website - https://studyopedia.com

► Subscribe
   / amittechie  

► Donate \u0026 Support us
https://www.paypal.com/paypalme/learn


Content

0.24 -> Hello guys welcome to Amit Thinks in this video we  will see how we can connect Python with MySQL that  
5.2 -> means we will install MySQL connector on Windows  10 and will connect both Python and MySQL so let's  
11.04 -> begin guys at first we will download and install  Python and pip then we will install MySQL let's  
16.48 -> begin with the download and installation of python  and paper let's start at first go to the browser  
24.24 -> I am using chrome you can use any browser here in  on google type python and press enter on pressing  
32.16 -> enter you can see the official website is visible  python.org click on it on clicking you can see  
38.72 -> the official website whenever you will keep the  mouse cursor on downloads the recent version will  
44.48 -> be visible so we want for windows so I'll click  on it this is the current version python 3.10.2  
50.4 -> click on it on taking the download started it's  only 26 mb you need to wait for few seconds
59.92 -> so guys you can see the exe file downloaded  now double click on it to install
67.12 -> minimize this now here you can see the setup  started at first set the python 3.10 to path  
74.24 -> so you can straight away click on install now but  I'll go for the customize installation click on it  
80.96 -> on clicking you can see it will install  documentation paper as well as ideally so pape  
85.92 -> is basically used to install other python packages  rest keep as it is and click on next here and you  
93.04 -> can see advanced option you can click on install  for all users after clicking you can see the path  
99.2 -> has been set its under program files or python  will get saved here if you want to change the  
104.32 -> location you can click on browse but i will keep  as it is click on install now the setup started
130.56 -> so guys you can see the setup  is successful click on close
136.48 -> so guys we successfully installed Python  and pip now let us install the current  
140.96 -> MySQL version let's begin we will see how  we can easily download and install MySQL  
146.64 -> server 8.0.28 on Windows 10 with that we  will also install mysql workbench and shell  
152.96 -> so shell is a command line tool that will allow  you to create database and tables and work on  
157.6 -> MySQL on command line so we will install all  three let's begin at first go to the browser  
164.48 -> i am using chrome you can use any  browser on google search type mysql  
171.12 -> press enter on pressing enter you can see the  official website is visible mysql.com click on it
179.12 -> after clicking go to downloads
184.16 -> after reaching downloads go below here  and click on MySQL community GPL downloads
190.96 -> after reaching here under community downloads  click on MySQL installer for Windows  
195.28 -> because you want for Windows here and you can  see the current version is MySQL installer 8.0.28  
202.96 -> the first one is a web installer and the  second one is what we will download and  
207.6 -> install it's 435 mb you can see 32 bit is  visible but this works for both 32-bit as  
214.08 -> well as 64-bit my system is 64-bit as you can  see here go to start type about click on open  
222.32 -> here and you can see my system  is 64-bit operating system okay
228.32 -> now we will download this click on it to download  
231.68 -> you don't need to log in just click  on no thanks just start my download  
236.48 -> you can see the download started for 36 mb  you need to wait for few seconds let's wait
246.24 -> so guys it got downloaded now double-click  on it to install minimize this
269.52 -> guys the installation started you need to choose  a setup type I'll go for the custom installation  
276 -> click on next after clicking next you can  see you need to select the products I told  
281.44 -> you I will go for MySQL server so I'll just go to  dropdown and here is the current one 8.0.28 just  
288.56 -> move it products to be install section now go to  applications we wanted workbench also here it is  
296.16 -> click on the following the last one what we  wanted guys we wanted shell which is command  
302.24 -> line and just drag it here so these three we  wanted so everything looks fine click on next
311.92 -> we need to click on execute to  install all of them click on execute
343.84 -> so guys you can see the  installation completed click on next
349.44 -> now it will configure the product click on next  again so guys here you can see Microsoft Visual  
357.68 -> Redistributable package is also needed for MySQL  installation so since we are already having this  
362.8 -> owner system it never showed us so guys we have  mentioned a link in the description of this video  
368.24 -> using which you can easily install Microsoft  visual c plus plus redistributable package  
373.2 -> after that you will reach here this is the  port number everything looks fine click on  
377.92 -> next here authentication method method keep  the default strong password click on next  
384.72 -> let us add a password so root is the admin so that  
387.76 -> is why it is asking for mysql root  password let us set up a password
396.4 -> so we use the following password you can directly  click on next here or you can also add a new user  
402.24 -> we are already having root user but we can but  you can also add an additional user by clicking  
406.8 -> add user here and set the name let's say my  user is amit and set it as localhost because  
413.12 -> we are working on a system a local system  role you can set as db admin on any other  
418.88 -> let's say i have set it as tpmanager create  a password for this neomit user and click  
425.04 -> on ok this will create a new user but i'll  click on cancel because root user is fine  
430.32 -> for me you can continue with this remember  this password this will be required  
435.28 -> later click on next now you can see windows  service mysql 80 it will it will start the  
440.88 -> mysql server at system startup everything looks  fine click on next now apply configuration step  
446.88 -> is visible all the steps will occur and your mysql  server shell and workbench will install completely  
453.12 -> click on execute this will also initialize the  database it will start the server also as well  
459.36 -> as work on all the security settings and other  stuff configuration and everything else let's wait
471.92 -> guys you can see here MySQL 8.0.28  configuration successful the installation  
477.68 -> is complete click on finish here is  the product configuration click on next  
483.04 -> you can see installation complete when i click  finish it will start MySQL workbench and MySQL  
488.4 -> shell but before that let us set the path at first  we will see the location wherein MySQL installed
498.56 -> it was in c drive program files here you can  see MySQL is visible click on it here it is  
506.88 -> MySQL server 8.0 bin and this this is  it right click and copy minimize this  
516 -> go to start type environment variables  
521.36 -> on typing edit the system environment variables  is visible this is what we wanted click on open  
527.36 -> after clicking system properties  advanced click on environment variables  
531.84 -> here in guys you can see path is visible  double click on it here in all the paths  
538.08 -> are set up click on new right click and paste  the same path so so we pasted the MySQL server  
546.96 -> bin path that's it click on ok click on ok and  click on last okay that's it we have set the path  
554.16 -> now I'll click on finish it will start the  MySQL workbench as well as shell click on finish
563.68 -> here it is
567.12 -> you can see the workbench is visible  
570.48 -> okay and the shell is here now let us go  to start type cmd click on open to open it  
578.4 -> here it is here it is now type a command MySQL  space hyphen hyphen version and press enter  
585.36 -> here you can see we successfully  installed mysql the same is visible 8.0.28  
589.68 -> now let's set a command mysql hyphen u  root hyphen p minus u is for user so we  
596 -> were having root user that's why i typed it  p is for password when you will press enter  
600.48 -> it will ask you to enter the password which  we entered before enter the same password
609.6 -> now press enter
612.64 -> if this is visible that means you  have successfully installed MySQL  
615.76 -> and you have started MySQL server okay guys here  in you can see i'll just type show databases  
624.24 -> semicolon press enter you can see these are the  default databases provider MySQL now let us create  
629.28 -> a database quickly create database amid db let's  say semicolon press enter and it got created this  
636.88 -> means one reflected it got created now use the  show databases command semicolon and press enter
645.52 -> here and you can see my db database got created in  this way you can create new databases and tables  
651.2 -> with that let us go to mysql workbench just click  on this you can see root is visible when you click  
657.36 -> on this it will ask you to add the same password  we added before under root add the same password
665.92 -> save it and click on ok
671.52 -> and you can see MySQL workbench started through  this also you can easily create a new database  
676.24 -> tables and work on other operations clauses  operators everything else so guys we successfully  
682.64 -> installed mysql as well now let us verify go  to start type cmd click on open to open it
692.24 -> now let us type MySQL space hyphen  hyphen version and press enter  
697.36 -> here you can see we successfully installed  MySQL now let us check for Python space  
701.68 -> hyphen hyphen version and press enter you  can see we successfully installed Python also  
707.52 -> now check for PIP pip space hyphen  hyphen version and press enter  
713.6 -> you can see we successfully installed  paper also now guys let us go to start  
717.68 -> and type ideally that is python idli  i have told you before click on open
724.4 -> so here it is guys so guys we need to connect  python with mysql so let us type let us import  
731.12 -> import mysql.connector
734.72 -> press enter now you can see it is showing an error  why because we haven't connected both of them we  
740.32 -> haven't installed anything for the connection  so we will install mysql connector quickly  
746.08 -> on the command prompt only guys  type the command paper install
754.32 -> mysql hyphen connector  hyphen python and press enter
762.64 -> so guys you need to have an internet  connection for this let's wait it is  
766.4 -> downloading and installing the connector
771.04 -> guys we have successfully installed the mysql  connector now guys let us go to start and type  
777.36 -> ideally that is python idli I have told you before  click on open so guys we have started our ideally  
785.36 -> now let us create a new notepad here right  click text document I'll just type example.py
795.76 -> py is the extension for Python I'll when i  press enter it will change the text document  
803.2 -> here it is now here is our code  I'll just right-click and open it
813.52 -> so I've opened it with Notepad now let us  write a code here it is guys I'll just save it  
822.56 -> okay now i'll go to file and I'll open  the file the same file on the desktop  
829.52 -> here it is example.py you can  see I'll just click on run
838.64 -> now here and you can see connection established
845.92 -> here is the code first we imported mysql.connector  so it was successful because we just installed it  
851.68 -> using pip we used a variable con and the  connect method within that you are having  
857.2 -> three parameters to connect that is host which  is localhost password and user are the same  
862 -> which we saw while installing mysql so i did  the same password and user if you remember  
868.24 -> root was our user then we went for is  connected method to check it using if  
873.6 -> statement that whether we have connected  python and mysql successfully or not and  
877.84 -> here we did that and the output we just  saw connection established here it is  
883.36 -> here it is guys so guys in this video we saw  how we can easily connect python with mysql  
888.32 -> using the connector first we installed python then  we installed mysql then we connected both of them  
893.92 -> so guys thank you for watching the video if you  liked it do subscribe to our channel with things

Source: https://www.youtube.com/watch?v=MhaH7o3lf4E