How to install Python MySQLdb module using pip?

+1 vote

How can I install the MySQLdb module for Python using pip?

Aug 1, 2018 in AWS by bug_seeker
• 14,970 points
456 views

2 answers to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
+1 vote

It's easy to do, but hard to remember the correct spelling:

pip install mysqlclient

If you need 1.2.x versions (legacy Python only), use pip install MySQL-python

Note: Some dependencies might have to be in place when running the above command. Some hints on how to install these on various platforms:

Ubuntu 14, Ubuntu 16, Debian 8.6 (jessie)

sudo apt-get install python-pip python-dev libmysqlclient-dev

Fedora 24:

sudo dnf install python python-devel mysql-devel redhat-rpm-config gcc

Mac OS

brew install mysql-connector-c

if that fails, try

brew install mysql

answered Aug 1, 2018 by Priyaj
• 56,120 points
0 votes

First

pip install pymysql

Then put the code below into init.py(projectname/init.py)

import pymysql
pymysql.install_as_MySQLdb()

My environment (python3.5,django1.10) and it work for me!

Hope help!!

answered Aug 1, 2018 by findingbugs
• 4,730 points

Related Questions In AWS

+13 votes
2 answers
0 votes
1 answer
0 votes
1 answer

How to Pass the VPC ID while creating the Ec2 instance in AWS using Python Boto3

import boto3 ec2 = boto3.resource('ec2') instance = ec2.create_instances( ...READ MORE

answered Jan 29 in AWS by Priyaj
• 56,120 points
131 views
0 votes
1 answer

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.