Python mysqldb Install

In this tutorial, we will follow step by step to install the mysql database and connector in python.

Data is very important for any organization to continue its operations. The data may be related to employees in the organization or the operational data like product information, raw material prices, sales information, profits and losses. Without data, no organization will survive. Hence, data is very important and it should never be lost

mysqldb installation steps:

To communicate with MySQL database from Python, we need a program that becomes an interface to the MySQL database server. 'MySQLdb' is an interface between the MySQL server and Python programs. Unless we install this interface, our Python programs cannot communicate with MySQL database. The following steps represent how to install the MySQLdb interface:

  1. Visit the following web page :

    mysqldb installation steps: > mysqldb installation steps: >
  3. The downloaded file name will be: mysqlclient-1.3.12-cp36-cp36m-win_amd64.whl, which is a .whl file. Such files cannot be executed by double clicking. We can execute such files using 'pip' program supplied with Python. Hence, go to that directory where this .whl file is available and type there pip command at System prompt as:
  4. D:\Python\mysql>pip install mysqlclient-1.4.2.post1-cp36-cp36m-win_amd64.whl

    mysqldb installation steps: > mysqldb installation steps: >

Install mysqldb connector

To connect the python application with the MySQL database, we must import the mysql.connector module in the program.

The mysql.connector is not a built-in module that comes with the python installation. We need to install it to get it working.

Execute the following command to install it using pip installer.

CopiedCopy Code
pip install mysql-connector
python Install mysql.connector