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
>>>

Thanks =)

For python3 and later use the next command: $ pip3 install mysql-connector-python-rf

Answer from Rishi on Stack Overflow
🌐
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. According to some stack exchange post its something to do with the newer (Python 3.0 and later) versions i believe.
Discussions

python - import mysql.connector could not be resolved pylance - Stack Overflow
And it's python 3.10 if I open a single file. Problem solved, you're my hero. Thank you so much. ... import mysql.connector ModuleNotFoundError: No module named 'mysql.connector'; 'mysql' is not a package More on stackoverflow.com
🌐 stackoverflow.com
Import Error. I can't import mysql-connector in Python - Stack Overflow
I have some problems trying to connect Python3 with MySql (8). I'm doing a programming course and the truth is that I still don't understand much. I already have the mysql-connector-python module More on stackoverflow.com
🌐 stackoverflow.com
python - ImportError: No module named mysql.connector using Python2 - Stack Overflow
If you have this error on PYCHARM: ImportError: No module named mysql.connector · Try this solution: Open Pycharm go to File->Settings-> Project->Python Interpreter inside Pycharm, Then press + icon to install mysql-connector. Problem solved! ... Thank you so much sir! I have been searching for this for 3 ... More on stackoverflow.com
🌐 stackoverflow.com
python - How to fix "Error: No module named mysql.connector" - Stack Overflow
I am working with some python program where I need to import mysql.connector. But I am facing ImportError: No module named connector. I already read answers on same issue and also explore google to... More on stackoverflow.com
🌐 stackoverflow.com
🌐
Stack Overflow
stackoverflow.com › questions › 71259511 › import-mysql-connector-could-not-be-resolved-pylance
python - import mysql.connector could not be resolved pylance - Stack Overflow
import mysql.connector mydb = mysql.connector.connect( host="localhost", user="yourusername", password="yourpassword" ) cursor = mydb.cursor() print(mydb)
🌐
Stack Overflow
stackoverflow.com › questions › 70375630 › import-error-i-cant-import-mysql-connector-in-python
Import Error. I can't import mysql-connector in Python - Stack Overflow
import mysql.connector ModuleNotFoundError: No module named 'mysql.connector'; 'mysql' is not a package ... Find the answer to your question by asking. Ask question ... See similar questions with these tags. ... 63 'Import "Path.to.own.script" could not be resolved Pylance (reportMissingImports)' in VS Code using Python 3.x on Ubuntu 20.04 LTS
🌐
Bobby Hadz
bobbyhadz.com › blog › python-no-module-named-mysql
ModuleNotFoundError: No module named 'mysql' in Python | bobbyhadz
April 4, 2024 - To solve the error, install the module by running the pip install mysql-connector-python command. Open your terminal in your project's root directory and install the mysql-connector-python module.
Find elsewhere
🌐
sebhastian
sebhastian.com › no-module-named-mysql
Python ModuleNotFoundError: No module named 'mysql' | sebhastian
February 28, 2023 - pip uninstall mysql-connector-python pip install mysql-connector-python==8.0.22 · Now the library should be able to run both in Python 2 or Python 3 environment.
🌐
Reddit
reddit.com › r/mysql › python3 mysql connector issue. help!!!
r/mysql on Reddit: Python3 Mysql Connector Issue. Help!!!
August 31, 2021 -

So i bought a linux server the other day, and followed this tutorial to install mysql: https://www.youtube.com/watch?v=WltqUaqxBH8

And I got no errors while running the mysql queries, but i get an error when i run my python file:

import mysql.connector


conn = mysql.connector.connect(
    host= '216.137.179.68',
    user='app',
    passwd="Cian62016!"
    )   


mycursor = conn.cursor()
mycursor.execute("SHOW DATABASES")

myresponce = mycursor.fetchone()

print(myresponce)
conn.close()

Error:

Traceback (most recent call last):
  File "mysqlConnectorTest.py", line 5, in <module>
    conn = mysql.connector.connect(
  File "/home/alexander/.local/lib/python3.8/site-packages/mysql/connector/__init__.py", line 179, in connect
    return MySQLConnection(*args, **kwargs)
  File "/home/alexander/.local/lib/python3.8/site-packages/mysql/connector/connection.py", line 95, in __init__
    self.connect(**kwargs)
  File "/home/alexander/.local/lib/python3.8/site-packages/mysql/connector/abstracts.py", line 716, in connect
    self._open_connection()
  File "/home/alexander/.local/lib/python3.8/site-packages/mysql/connector/connection.py", line 208, in _open_connection
    self._do_auth(self._user, self._password,
  File "/home/alexander/.local/lib/python3.8/site-packages/mysql/connector/connection.py", line 137, in _do_auth
    packet = self._protocol.make_auth(
  File "/home/alexander/.local/lib/python3.8/site-packages/mysql/connector/protocol.py", line 99, in make_auth
    packet += self._auth_response(client_flags, username, password,
  File "/home/alexander/.local/lib/python3.8/site-packages/mysql/connector/protocol.py", line 58, in _auth_response
    auth = get_auth_plugin(auth_plugin)(
  File "/home/alexander/.local/lib/python3.8/site-packages/mysql/connector/authentication.py", line 190, in get_auth_plugin
    raise errors.NotSupportedError(
mysql.connector.errors.NotSupportedError: Authentication plugin 'caching_sha2_password' is not supported

And the mysql connector was just installed using:

pip3 install mysql.connector

Any Thoughts on how to help would be greatly appreciated!!!

Thanks!

🌐
Delft Stack
delftstack.com › home › howto › python › importerror no module named mysql.connector
How to Fix ImportError: No Module Named mysql.connector | Delft Stack
March 11, 2025 - The most straightforward way to resolve the ImportError is to install the mysql-connector-python package. This package provides the necessary tools to connect to a MySQL database using Python.
🌐
Latenode
community.latenode.com › other questions › mysql
Cannot resolve mysql.connector module import error - MySQL - Latenode Official Community
July 25, 2025 - Hey everyone, I’m facing a really annoying problem with my Python code. It keeps giving me an import error for the mysql.connector module. I went ahead and installed the package using pip install mysql-connector-python, and the installation went smoothly. Yet, when I try to execute my script, ...
🌐
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 - ModuleNotFoundError Traceback (most recent call last in----> 1 import mysql.connector ModuleNotFoundError: No module named 'mysql' ... You need to install a mysql-connector to connect Python with MySQL.
🌐
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. pypy3 mysql_temp.py1 eraser 2 banana 3 apple 4 orange 5 ballpoint-pen
🌐
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 ...
🌐
Pipedream
pipedream.com › bugs
Python: Can't use mysql.connector, getting No module named '_version' - Bugs - Pipedream
May 27, 2022 - I just added a step and just by writing import mysql.connector from pipedream.script_helpers import (steps, export) import mysql.connector # Reference data from previous steps print(steps["trigger"]["context"]["id"]) …
🌐
Stack Overflow
stackoverflow.com › questions › 69996049 › cant-import-mysql-connector-in-python
Cant import mysql.connector in python - Stack Overflow
import mysql.connector db = mysql.connector.connect ( host='localhost', user='oscar', pwd='password', database='gpro1' ) cursor = db.cursor (dictionary = True) cursor.execute ("CREATE TABLE IF NOT EXISTS TestTable (id INTEGER)") for i in range (0,100): cursor.execute (f"INSERT INTO TestTable VALUE({i})") db.commit ()
🌐
Stack Overflow
stackoverflow.com › questions › 57589885 › can-not-import-mysql-connect
python - Can not import mysql.connect - Stack Overflow
August 21, 2019 - Copy/Users/mymac/anaconda3/bin/python /Users/mymac/PycharmProjects/test_python/mysql.py Traceback (most recent call last): File "../mysql.py", line 1, in [module] import mysql.connector File "../mysql.py", line 1, in [module] import mysql.connector ModuleNotFoundError: No module named 'mysql.connector'; 'mysql' is not a package ... If you're using anaconda, the pip commands are irrelevant. Are you sure you're starting the correct interpreter? Are you using virtual environments? ... I am not using virtualenv. but conda install command does not work too. ... What is the name of the file where you want to import the connector with that import mysql.connector statement?