Resolving ModuleNotFoundError: No module named 'mysql' Error in Python

In this Python tutorial page I will show how to resolve ModuleNotFoundError: No module named 'mysql' in Python.

Resolving ModuleNotFoundError: No module named 'mysql' Error in Python

ModuleNotFoundError: No module named 'mysql' - Steps to resolve 'mysql' module not found error

In this tutorial we are going to learn the steps to install the mysql connector module for Python for resolving the ModuleNotFoundError: No module named 'mysql' error. If you are trying to use the mysql-connector module in Python and you are not able to import the module then it is due to unavailability of this module in your Python installation package.

ModuleNotFoundError: No module named 'mysql' - Steps to resolve 'mysql'

In this section I will show you the steps to install the 'mysql-connector-python' module in your Python installation and use this package in your Python program. So, let's get started.

What is the 'mysql-connector-python' module?

The mysql-connector-python module is a Python package for connecting to MySQL Database server from a Python program and performing database operations using SQL. You can learn more about SQL at Introduction to SQL.

How to mysql connector module for Python?

The installation process is easy and you can install it by running following pip command in your terminal:


pip install mysql-connector-python

Above pip command will download mysql connector module of Python along of dependent packages and install in your Python environment. After successful installation of the package you will be able to import mysql connector package in your Python program.

How to import MySQL connector package in Python program?

This is the Python code to import mysql connector library in Python program:


import mysql.connector

We have also recorded the video tutorial to explain you the steps. Here is the video tutorial of resolving error - ModuleNotFoundError: No module named 'mysql'.

Above video explains you the process of installing mysql-connector module in Python. Here are related tutorials: