I was facing the similar issue. My env details - Python 2.7.11 pip 9.0.1 CentOS release 5.11 (Final)

Error on python interpreter -

>>> import mysql.connector
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named mysql.connector
>>>

Use pip to search the available module -

 $ pip search mysql-connector | grep --color mysql-connector-python



mysql-connector-python-rf (2.2.2)        - MySQL driver written in Python
mysql-connector-python (2.0.4)           - MySQL driver written in Python

Install the mysql-connector-python-rf -

$ pip install mysql-connector-python-rf

Verify

$ python
Python 2.7.11 (default, Apr 26 2016, 13:18:56)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-54)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import mysql.connector
>>>
Answer from Rishi on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › python › modulenotfounderror-no-module-named-mysql-in-python
Modulenotfounderror: No Module Named Mysql in Python - GeeksforGeeks
July 23, 2025 - Module Not Installed: The MySQL connector module might not be on your system, which means Python can’t find it. Incorrect Module Name: Python is case-sensitive, so even a small typo or wrong capitalization when importing the module can cause an error.
🌐
Reddit
reddit.com › r/mysql › python can not import mysql
r/mysql on Reddit: Python can not import mysql
June 22, 2022 - For anyone facing this issue today.. in command prompt or whatever u used to install (idk im a newbie) instead of pip install i tried pip3 install mysql-connector-python and then imported mysql.connector in python and it worked then. Earlier it wasn't as I only used pip install.
🌐
Bobby Hadz
bobbyhadz.com › blog › python-no-module-named-mysql
ModuleNotFoundError: No module named 'mysql' in Python | bobbyhadz
April 4, 2024 - Not having the mysql-connector-python package installed by running pip install mysql-connector-python. Installing the package in a different Python version than the one you're using.
🌐
sebhastian
sebhastian.com › no-module-named-mysql
Python ModuleNotFoundError: No module named 'mysql' | sebhastian
February 28, 2023 - This error occurs because the Python compiler can’t find a package named mysql in your Python environment. Let’s see an example that causes this error and how to fix it. Suppose you try to connect to a MySQL database using Python with the following code: import mysql.connector # Connect to MySQL database server db = mysql.connector.connect( host="127.0.0.1", port=3306, user="root", password="root")
🌐
JanBask Training
janbasktraining.com › community › sql-server › how-to-resolve-the-modulenotfounderror-no-module-named-mysql
How to resolve the modulenotfounderror: no module named \'mysql\'? | JanBask Training Community
June 6, 2024 - There are several MySQL connector modules available for Python. The most common ones are: ... You can install the required module using pip. Open your terminal or command prompt and run one of the following commands: ... If there are no errors, the module is installed correctly. ... Here are basic examples of how to use each module to connect to a MySQL database. ... import mysql.connector# Establish the connectionconn = mysql.connector.connect( host="your_host", user="your_username", password="your_password", database="your_database")# Create a cursor objectcursor = conn.cursor()# Execute a querycursor.execute("SELECT * FROM your_table")# Fetch the resultsresults = cursor.fetchall()# Print the resultsfor row in results: print(row)# Close the connectionconn.close()
Find elsewhere
🌐
Medium
resotto.medium.com › modulenotfounderror-no-module-named-mysql-connector-mysql-is-not-a-package-bfc7256a91b5
ModuleNotFoundError: No module named ‘mysql.connector’; ‘mysql’ is not a package | by resotto | Medium
August 24, 2019 - In short, I imported not mysql-connector-python module, but my own mysql module. ... Actually, ‘mysql’ was module of my own. So, I changed the program name to mysql_temp.py , and it worked well.
🌐
MLJAR
mljar.com › modulenotfounderror › no-module-named-mysql
No module named mysql
import sys !{sys.executable} -m pip install mysql-connector-python
🌐
Stack Abuse
stackabuse.com › bytes › fixing-modulenotfounderror-no-module-named-mysql-in-python
Fixing "ModuleNotFoundError: No module named 'mysql'" in Python
August 14, 2023 - The ModuleNotFoundError: No module named 'mysql' error is encountered when you try to import the MySQL module in your Python script but the interpreter fails to locate it. This usually means that the MySQL module is not installed in your Python environment.
🌐
Stack Overflow
stackoverflow.com › questions › 77858411 › import-mysql-connector-modulenotfounderror-no-module-named-mysql
import mysql.connector, ModuleNotFoundError: No module named 'mysql' - Stack Overflow
Do you have other python version in the system? try using python3 -m pip install mysql-connector-python to install it, then again it python3 -c 'import mysql.connector'
🌐
Python.org
discuss.python.org › python help
Windows 11 - Python mysql import error - Python Help - Discussions on Python.org
March 1, 2025 - ‘’’ This code was running with no issues and connecting to a remote mysql DB and not sure why it is failing now with this error. Appreciate any help as I am new to python. The ERROR Traceback (most recent call last): File “C:/PROJECTS/Python/mySQL/mySQL_Forum.py”, line 2, in from mysql.connector import Error ImportError: cannot import name ‘Error’ from ‘mysql.connector’ (unknown location) I have masked out my clients db credentials which are correct, the database server is running.
🌐
Ask Ubuntu
askubuntu.com › questions › 1446028 › modulenotfounderror-no-module-named-mysql
python - ModuleNotFoundError: No module named 'mysql' - Ask Ubuntu
December 17, 2022 - I add in rc.local /usr/bin/python3 /usr/bin/test.py , for this I have error import mysql.connector as mysql ModuleNotFoundError: No module named 'mysql' When I removed connection to mysql , is ok I tested : python3 /usr/sbin/test.py working good , connection to mysql is ok .
🌐
Chanmingman's Blog
chanmingman.wordpress.com › 2023 › 04 › 23 › modulenotfounderror-no-module-named-mysql-connector-mysql-is-not-a-package
ModuleNotFoundError: No module named ‘mysql.connector’; ‘mysql’ is not a package | Chanmingman's Blog
April 24, 2023 - In the actual fact, in order to connect to MySQL in Windows, you only need to install this https://dev.mysql.com/downloads/connector/python/. Do Not name your file as mysql.py. Everything is running fine after I rename the mysql.py to mymy.sql. You can try the code below. Source code download: https://github.com/chanmmn/PythonSQLServer/tree/master/py/?WT.mc_id=DP-MVP-36769 · Reference: https://resotto.medium.com/modulenotfounderror-no-module-named-mysql-connector-mysql-is-not-a-package-bfc7256a91b5
🌐
Slideshare
slideshare.net › home › technology › modulenotfounderror no module named 'mysql' in python
Modulenotfounderror No module named 'mysql' in Python | PDF
To fix that, we use the command below sudo pip3 install mysql-connector-python sometimes you won't get pip in the PATH environment variable then we use the bellow command to fix that error python -m pip install mysql-connector-python if you get the same error while working in python 3, then we use the below command for it python3 -m pip install mysql-connector-python for anaconda, we use the below command conda install -c anaconda mysql-connector-python ... After installing themysql-connector-python, we have to import that again in the code to use it.