Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install mysql-connector via pip

I use sqlalchemy to access MySQL in my Python project. sqlalchemy's conf is like this:

dialect=mysql
driver=mysqlconnector

So I need to install the Python module mysql connector via pip. Any help?

like image 893
Codefor Avatar asked Sep 24 '15 06:09

Codefor


People also ask

How do I install MySQL connector Python?

Installation: To install Python-mysql-connector module, one must have Python and PIP, preinstalled on their system. To check if your system already contains Python, go through the following instructions: Open the Command line(search for cmd in the Run dialog( + R).


4 Answers

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

like image 171
Partha Sen Avatar answered Oct 17 '22 04:10

Partha Sen


To install the official MySQL Connector for Python, please use the name mysql-connector-python:

pip install mysql-connector-python

Some further discussion, when we pip search for mysql-connector at this time (Nov, 2018), the most related results shown as follow:

$ pip search mysql-connector | grep ^mysql-connector
mysql-connector (2.1.6)                  - MySQL driver written in Python
mysql-connector-python (8.0.13)          - MySQL driver written in Python
mysql-connector-repackaged (0.3.1)       - MySQL driver written in Python
mysql-connector-async-dd (2.0.2)         - mysql async connection
mysql-connector-python-rf (2.2.2)        - MySQL driver written in Python
mysql-connector-python-dd (2.0.2)        - MySQL driver written in Python
  • mysql-connector (2.1.6) is provided on PyPI when MySQL didn't provide their official pip install on PyPI at beginning (which was inconvenient). But it is a fork, and is stopped updating, so

    pip install mysql-connector
    

    will install this obsolete version.

  • And now mysql-connector-python (8.0.13) on PyPI is the official package maintained by MySQL, so this is the one we should install.

like image 20
YaOzI Avatar answered Oct 17 '22 06:10

YaOzI


pip install mysql-connector

Last but not least,You can also install mysql-connector via source code

Download source code from: https://dev.mysql.com/downloads/connector/python/

like image 26
Codefor Avatar answered Oct 17 '22 06:10

Codefor


execute following command from your terminal

sudo pip install --allow-external mysql-connector-python mysql-connector-python
like image 7
Zaheer Khorajiya Avatar answered Oct 17 '22 05:10

Zaheer Khorajiya