Django Install MySQL Driver

Source: Internet
Author: User
Tags mysql client

Django currently supports three MySQL drivers for MySQL links

    • MySQLdb is a native driver that have been developed and supported for Overa decade by Andy Dustman.

    • Mysqlclient is a fork of MySQLdb which notably supports Python 3 Andcan being used as a drop-in replacement for MYSQLDB. At the time of this writing,this are the recommended choice for using MySQL with Django.

    • MySQL Connector/python is a pure Python driver from Oracle, does notrequire the MySQL client library or any Python mod Ules outside the standardlibrary.

MYSQLDB currently does not support python3+, it is recommended to use Mysqlclient

Tried to install mysqlclient directly on Pycharm, reported the following error: Oserror:mysql_config not found

Check the installation steps on Git:


Need to install the Python and MySQL development headers and libraries as so:

sudo apt-get install python-dev libmysqlclient-dev# Debian/ubuntu

sudo yum install python-devel mysql-devel# Red Hat/centos

On Windows, there is binary wheel you can install without mysqlconnector/c or MSVC.

Note on Python 3:if you is using python3 then you need to install Python3-dev using the following command:

sudo apt-get install python3-dev# Debian/ubuntu

sudo yum install python3-devel# Red Hat/centos

brew install mysql-connector-c# MacOS (Homebrew)

Install from PyPI

pip install mysqlclient

Because I'm using the Python3 on my Mac, I'm going to execute the command first:

brew install mysql-connector-c

And then do it again:

PIP3 Install Mysqlclient

The following error is reported:

Command "python egg_info" failed with error code 1 in/private/tmp/pip-build-m9v70gan/mysqlclient/

Oddly, after using the PIP3 command, the final call is Python, not python3

Django Install MySQL Driver

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.