If loading via pip install mysql-connector and leads an error Unable to find Protobuf include directory then this would be useful pip install mysql-connector==2.1.4

mysql-connector is obsolete, so use pip install mysql-connector-python. Same here

Answer from Partha Sen on Stack Overflow
🌐
MySQL
dev.mysql.com β€Ί doc β€Ί dev β€Ί connector-python β€Ί latest β€Ί installation.html
Installation β€” MySQL Connector/Python X DevAPI Reference 9.7.0 documentation
To install Connector/Python from a tar archive, download the latest version (denoted here as <version>), and execute these commands: shell> tar xzf mysqlx-connector-python-<version>.tar.gz shell> cd mysqlx-connector-python-<version>.tar.gz shell> python setup.py install --with-protobuf-include-dir=<protobuf-include-dir> --with-protobuf-lib-dir=<protobuf-lib-dir> --with-protoc=<protoc-binary>
🌐
PyPI
pypi.org β€Ί project β€Ί mysql-connector-python
mysql-connector-python Β· PyPI
Please, refer to the official MySQL documentation Connector/Python Installation to know more about installing from an RPM, or building and installing a WHEEL package from a source distribution. Before installing a package with pip, it is strongly suggested to have the most recent pip version installed on your system. If your system already has pip installed, you might need to update it. Or you can use the standalone pip installer. ... Connector packages included in MySQL Connector/Python allow you to install optional dependencies to unleash certain functionalities.
      Β» pip install mysql-connector-python
    
Published Β  Apr 23, 2026
Version Β  9.7.0
🌐
W3Schools
w3schools.com β€Ί python β€Ί python_mysql_getstarted.asp
Python MySQL
Navigate your command line to the location of PIP, and type the following: ... C:\Users\Your Name\AppData\Local\Programs\Python\Python36-32\Scripts>python -m pip install mysql-connector-python
🌐
GeeksforGeeks
geeksforgeeks.org β€Ί python β€Ί how-to-install-mysql-connector-package-in-python
How to install MySQL Connector Package in Python - GeeksforGeeks
July 12, 2025 - Thus, it generates a connection between the programming language and the MySQL Server. To install Python-mysql-connector module, one must have Python and PIP, preinstalled on their system.
🌐
MySQL
dev.mysql.com β€Ί doc β€Ί connector-python β€Ί en
MySQL :: MySQL Connector/Python Developer Guide
This manual describes how to install and configure MySQL Connector/Python, a self-contained Python driver for communicating with MySQL servers, and how to use it to develop database applications. The latest MySQL Connector/Python version is recommended for use with MySQL Server version 8.0 and higher. For notes detailing the changes in ...
🌐
MySQL
dev.mysql.com β€Ί doc β€Ί connector-python β€Ί en β€Ί ch04s04s01.html
MySQL :: MySQL Connector/Python Developer Guide :: 4.4.1 Installing Connector/Python with pip
# Installation $> pip install mysql-connector-python # Upgrade $> pip install mysql-connector-python --upgrade # Optionally, install X DevAPI $> pip install mysqlx-connector-python # Upgrade X DevAPI $> pip install mysqlx-connector-python --upgrade Β· In case the wheel package you want to install ...
🌐
Anaconda.org
anaconda.org β€Ί anaconda β€Ί mysql-connector-python
mysql-connector-python - anaconda | Anaconda.org
2 weeks ago - Sign In Sign Up Β· anaconda/mysql-connector-python Β· Anaconda Verified Β· Python driver for communicating with MySQL servers Β· Overview Β· Files 186 Β· Labels 1 Β· Badges Β· Versions Β· 9.7.0 Β· To install this package, run one of the following: $conda install anaconda::mysql-connector-python Β·
Find elsewhere
🌐
MySQL
dev.mysql.com β€Ί doc β€Ί connector-python β€Ί en β€Ί connector-python-installation.html
MySQL :: MySQL Connector/Python Developer Guide :: 4 Connector/Python Installation
If your system does not have Python preinstalled for some reasons, use its software management system to install it. For Microsoft Windows, a Python installer is available at the Python Download website or via the Microsoft Store. Also make sure Python in your system path.
🌐
PYnative
pynative.com β€Ί home β€Ί python β€Ί databases β€Ί install mysql connector python on windows, macos, linux, unix and ubuntu
Install MySQL Connector Python on Windows, MacOs, Linux, Unix and Ubuntu
March 9, 2021 - There are two ways to install MySQL Connector Python on windows. Install using Source Code Distribution ( Platform Independent and Architecture Independent ZIP Archive)
🌐
MySQL
dev.mysql.com β€Ί doc β€Ί connector-python β€Ί en β€Ί connector-python-installation-source.html
MySQL :: MySQL Connector/Python Developer Guide :: 4.5 Installing Connector/Python from a Source Distribution
We recommend leveraging python virtual environments to encapsulate the package installation instead of installing packages directly into the Python system environment. ... Download the latest version of the sdist of Connector/Python for the classic MySQL protocol, whose name is in the format of mysql_connector_python-x.y.z.tar.gz.
🌐
MySQL
dev.mysql.com β€Ί doc β€Ί connector-python β€Ί en β€Ί quick-installation-guide.html
MySQL :: MySQL Connector/Python Developer Guide :: 4.1 Quick Installation Guide
# classic API $ pip install mysql-connector-python # X DevAPI $ pip install mysqlx-connector-python Β· Refer to the installation tutorial for alternate means to install X DevAPI.
🌐
YouTube
youtube.com β€Ί watch
How to Install MySQL Connector for Python (2024) - YouTube
In this video, I'll show you how you can install MySQL connector for python and how you can connect to msyql database from mysql connector.MySQL connector fo...
Published Β  June 13, 2024
🌐
MySQL
dev.mysql.com β€Ί doc β€Ί connector-python β€Ί en β€Ί connector-python-installation-binary.html
MySQL :: MySQL Connector/Python Developer Guide :: 4.4 Installing Connector/Python from a Binary Distribution
MySQL Connector/Python Developer Guide / Connector/Python Installation / Installing Connector/Python from a Binary Distribution ... Connector/Python includes the classic and X DevAPI connector APIs, which are installed separately.
🌐
YouTube
youtube.com β€Ί watch
how to download and install mysql connector for python - YouTube
#SimpleSnipCode #mysql.connectorpip command :- pip install mysql-connector-pythonQuery:-How to Download and Install MySQL and Python Connector (Hindi)Python ...
Published Β  November 25, 2020
🌐
CodeSpeedy
codespeedy.com β€Ί home β€Ί how to install mysql connector in python
How to install MySQL Connector in Python - CodeSpeedy
February 9, 2019 - So here we gonna install MySQL Connector with the help of pip. ... Step 2- Goto C:\Users\Username\AppData\Local\Programs\Python\Python37-32\Scripts ( Username will be your username, Python37-32 is my version, try to show hidden files too if you can’t find these folders)
🌐
Estuary
estuary.dev β€Ί blog β€Ί mysql-connectors
How To Set Up And Configure MySQL Connectors: Full Guide
June 8, 2026 - Run the installer and select MySQL Connector/Python as one of the products to install.
🌐
Devart
docs.devart.com β€Ί python β€Ί mysql β€Ί install-the-connector-on-windows.htm
Install the connector on Windows - Python Connector for MySQL
You can install the connector from the Python Package Index (PyPI) or a wheel (.whl) file. Open Command Prompt. Verify that you have the pip package installer on your system using the py -m pip --version command. If you don't have it, run the following command to install pip.
Top answer
1 of 4
18

There are two ways to install MySQL connector. The second way is preferred.

1. MySQL Installer

This is Oracle's product installer. The problem is that it is outdated. It is only aware of Python version 3.6, and nothing newer. To install for a newer version of Python, use option 2.

2. Python package manager, pip

The Python package manager comes with Python, called pip. It downloads the package from the PyPI repository and installs it in an automatic location based on what version of Python (or what virtual copy) you use to install it. The package that you want is mysql-connector-python. In fact, the official documentation says this is the recommended method for installing the MySQL Connector.

For example, on Windows, open up the Command Prompt (cmd.exe) by searching in the Start Menu. Navigate to the directory where pip is installed. Or make sure that pip's directory is included in the $PATH variable (which you can edit by searching for "PATH" in the Start Menu).

The command prompt will show you this:

PS C:\Users\Ryan> 

except instead of my username, it'll show your username, or the path you navigated to after you found pip, like "C:\blah\blah". Then use this command...

Input:

pip install mysql-connector-python

It downloads and installs it.

Results:

PS C:\Users\Ryan> pip install mysql-connector-python
Collecting mysql-connector-python
Downloading https://files.pythonhosted.org/packages/2d/65/3fc902c0f7635912800c6b935313b99b9d4426419ef7ba04f76231b24923/mysql_connector_python-8.0.12-py2.py3-none-any.whl (300kB)
    100% |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 307kB 1.1MB/s
Collecting protobuf>=3.0.0 (from mysql-connector-python)
Downloading https://files.pythonhosted.org/packages/77/78/a7f1ce761e2c738e209857175cd4f90a8562d1bde32868a8cd5290d58926/protobuf-3.6.1-py2.py3-none-any.whl (390kB)
    100% |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 399kB 1.8MB/s
Requirement already satisfied: setuptools in c:\users\ryan\appdata\local\programs\python\python37\lib\site-packages (from protobuf>=3.0.0->mysql-connector-python) (40.4.3)
Collecting six>=1.9 (from protobuf>=3.0.0->mysql-connector-python)
Using cached https://files.pythonhosted.org/packages/67/4b/141a581104b1f6397bfa78ac9d43d8ad29a7ca43ea90a2d863fe3056e86a/six-1.11.0-py2.py3-none-any.whl
Installing collected packages: six, protobuf, mysql-connector-python
Successfully installed mysql-connector-python-8.0.12 protobuf-3.6.1 six-1.11.0

Afterward, you can make sure it is installed by displaying all packages that have been installed by you (not including standard libraries, which come with Python):

Input:

PS C:\Users\Ryan> pip list

Results:

Package                Version
---------------------- -------
mysql-connector-python 8.0.12
pip                    18.0
protobuf               3.6.1
setuptools             40.4.3
six                    1.11.0

To check if you installed it to the right version of Python, use pip -V. To make sure you installed it to the right copy (virtual or original), look at the file path where the package was installed:

PS C:\Users\Ryan> pip -V

Results:

pip 18.0 from c:\users\ryan\appdata\local\programs\python\python37\lib\site-packages\pip (python 3.7)

For example, in my system, it shows python37 in the folder path, so it installed it to the original Python 3.7.0 installation I have, instead of an older version or virtual environment (conda or virtualenv, etc).

To check the version using the Python executable, instead of pip:

PS C:\Users\Ryan> py -V
Python 3.7.0

If you need to install it to an older or newer Python version than the default installation, insert the version number as an option (aka. "switch") in the command, using -. For example, to select version 3.6:

py -3.6 -m pip install mysql-connector-python

The - works on both Windows and Unix-like OSs.

2 of 4
11

mysqlclient supports python3.7 officially, you can find it here :

https://pypi.python.org/pypi/mysqlclient

1)you can download , PyMySQL 0.9.2
2)extract & copy the folder pymysql into the python Lib folder
3)and for connection you can do like this(make a file for example freeman.py):

#!/usr/bin/env python

import pymysql

conn = pymysql.connect(host='localhost', port=3306, user='root', passwd='', db='freemanDB')

cur = conn.cursor()
cur.execute("SELECT * FROM users")

print(cur.description)
print()

for row in cur:
    print(row)

cur.close()
conn.close()