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
• 15,360 points
1,634 views

2 answers to this question.

+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,960 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,770 points

Related Questions In AWS

+13 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 26, 2018 in DevOps & Agile by DragonLord999
• 8,380 points
245 views
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,960 points
416 views
0 votes
1 answer