How to install MySQL Connector in Python

In this Python tutorial, we will talk about how to install MySQL Connector in Python. So before jumping to installation let’s talk about why we need this MySQL Connector and a little bit introduction. If you are familiar with these things you may jump to the installation process below.

What is MySQL Connector and Why we need this in Python

MySQL Connector for Python is a database driver that can help you to build a connection between your MySQL database and Python program.

Suppose you have a MySQL Database and you need to work with the database in a Python program. Then you must need to have a Connector which will build a connection between the Database and your program.

Here MySQL Connector/Python will build the connection between your database and Python program. Thus we need MySQL Connector for our Python program to work with MySQL Database.

Note: This connector is named as MySQL Connector/Python

How to install MySQL Connector/Python

We can Install MySQL Connector in Python with various methods. But as you know CodeSpeedy always tries to choose the easiest way to do any task.

So here we gonna install MySQL Connector with the help of pip.

  • Step 1- Open your command prompt ( cmd )
  • Step 2- Goto
    ( Username will be your username, Python37-32 is my version, try to show hidden files too if you can’t find these folders)
  • Open cmd in this directory or open cmd and locate to that above directory
  • type pip install mysql-connector in your cmd
  • hit enter and your downloading and installation process will automatically be started.

You can use these below commands:

pip install mysql-connector
pip install mysql-connector-python

Both will work.

This is the easiest process as you don’t have to download and install from an external website as pip will make sure that your installation is done successfully.

How to insert data into MySQL Table in Python Programming

But still, if you are curious about how to install MySQL Connector/Python without pip. Then follow these steps:

Install MySQL Connector/Python without pip

Just go to this webpage:

And download the MySQL Connector for Python for your OS.

You can use the above commands. Or just take a look at the documentation on the above mentioned official link.

You may also learn,

One response to “How to install MySQL Connector in Python”

  1. Ronit Pal says:

    really helped thankyouuu soo much!!!

Leave a Reply

Your email address will not be published. Required fields are marked *