Integrate MySQL and Python

Jagpreet Kaur
AI Perceptron
Published in
7 min readOct 6, 2020

In this blog, we will see how to install MySQL and python connector/driver.

Firstly, go to the Google page and search MySQL, you will find the official website of MySQL on the first option itself “www.mysql.com”.

After reaching on the website page go and click the” DOWNLOADS”.

Scroll down the window and you will need to click on the “MySQL Community (GPL) Downloads” option.

This will take you to another page which contains all different MySQL components, if you are a Windows user you need to click on the option “MySQL Installer for Windows” as shown below.

[U can also install MySQL Community Server and Connector/Python Separately, if you want to install any component separately you can directly click on the link and install that. If you are a mac, ubuntu, or any other OS user; you can install MySQL Community Server]

After clicking on “MySQL Installer for Windows” you will be able to see a screen as referred below.

[MySQL installer contains a package of MySQL Server, MySQL Connector, MySQL Workbench, Sample Databases, MySQL for Excel, MySQL Notifier, MySQL for Visual Studio, Documentation]

Now click on the “Download” option to start your installation.

After downloading double click on the .exe file which will be downloaded and a pop-up window will arise asking for “Do you want to run this file

Click on the “Run” button and installation will start. After a few minutes an administrator message will arise, “Do you want this program to make changes in your device “. Click on the “yes “option to proceed.

After installation you will be able to see a screen as shown below:

Click on I accept the license terms and then click on “Next

After that, you will be asked to choose a setup type, click on “Developer Default ”. [We can also click on Custom Option if we do not want all the MySQL components to be installed]. But we have installed developer default as, if we need any more components in the future we can use them directly.

Now after selecting Developer Default. Click on “Next”.

After clicking Next it can ask you for Check Requirements, you can click on Execute and start installing “MySQL for Visual Studio” or else you can directly click on “Next” and skip this installation as it is not needed for us, click on ”yes” and bypass if it says“requirement has been not satisfied”.

U will see a window in which different components will be ready to install.

Click on “Execute”, as shown above, and one by one they will start installing, it can take a few minutes.

After completion of installation of all the components, click on the “Next” button. We will get a configuration option to configure MySQL Server, MySQL Router, Samples and Examples.

In the High Availability, leave it as default for “Standalone MySQL Server/Classic MySQL Replication “ and then click on “Next”.

Now in the next window “Type and Networking,” you will be able to see Config Type, we need to keep it “Development Computer “, as we are going to use it for development purpose [Once take a look at the port, if you have already used that port changes the port number] and then click on “Next”.

You will see an “Authentication Method” we can click on any of the options but as it is recommended we will keep it default “Use Strong Password Encryption for Authentication (RECOMMENDED) ” and then click on “Next”.

Now in the next step, we are going to set a password for the root account username.[Please note down and save your password in notepad as we are going to use it in future]

Enter the same password in both the options as highlighted above and then click on “Next”. [We can also create our own user using the “Add User “, it will ask for username: (enter username whatever you want), host:(leave host as default i.e. Localhost), Role: (you can change the role according to you or else keep it as default DB Admin), password:(set your own password for your user name and confirm password and press ok)

After clicking on next you will see ” Windows Service “.

Uncheck the option highlighted in the screenshot below and click on “Next”.

You will see an Apply Configuration, Click on “Execute” to start the execution.

After Completion of Configuration.

Click on “Finish”.

We can see below the Configuration for MySQL Server is completed.

Now, click on “Next” this time the configuration will be for MySQL Router, but we can skip this by clicking on Next.

Then directly without making any changes click on “Finish”.

After this you will again see the window of Product Configuration that will be now for” Samples and Examples” again click on “Next” and you will see a window containing user name as root and password to be entered “Enter the same password” which we have set before and click on “Check.

And you can see the status as “connection succeeded”.[If you have written a wrong password then it will show “Connection Failed ”]. Then click on “Next” and then click on “Execute”.

And after clicking on Execute the configuration will start and complete and then you will see a window as displayed above, then click on the “Finish” button. This will again take you to the Product Configuration window, all the configurations are completed. Now, you need to just click on “Next”.

Installation Completed Window will be displayed just uncheck the two checkboxes to avoid the start of MySQL Shell and Workbench after the setup and then click “Finish”.

Our installation is done.

Now, to check whether MySQL is installed or not, we need to open cmd

Go, to start, search, and type cmd and open it.

After that go to C: Drive, Program Files, you will see a folder named MySQL, open it and go to MySQL Server then go to the bin.

Click on the above path bar and select the path as shown below.

And paste on the cmd prompt, and set the path as shown below, make few changes by looking at the screenshot below.

From here, we can login into MySQL, we need to login into our MySQL, by writing the code

mysql –u root –p (and then press enter it will ask for password)

After entering the password which we have used while installing press enter and you will enter in MySQL.

Now, we have seen MySQL installation along with python Connector … we will now install python and create a database in python.

To install python follow any one of the below instructions

After installation of python. lets, make connectivity with SQL Database and run our code on the python platform ie.python shell. We will also see how to create a table using SQL code in python.

Click on the below link to proceed :

To Learn python more — Check our video tutorials on youtube

--

--