Python - Installieren Sie MySQLDB auf EC2

Ref: [1] - Problem with installing ‘MySQLdb’ in Python [2] - Stackoverflow - How to install MySQLdb (Python data access library to MySQL) on Mac OS X? [3] - Python MySQL for EC2 Amazon AMI

Since the version of MySQLDB was changing in the old days, the instructions about how to install this useful tool varies a lot, which makes this tool is very hard to install.

Among all these instructions I found, I find they are not for the current version of MySQLDB. And some steps mentioned by these instructions are not necessary.

So I'm just going to give my install procedure. Hope it will help someone.

The MySQLDB I'm using is the MySQL-python-1.2.4b4.

Step 1

Make sure you have install gcc, mysql-devel and of cource mysql. If not, follow this post.

Step 2

Although most EC2 instance will be with python, but still you will need python-devel.

yum install python-devel

Note that this may need admin user.

Step 3

Download the source code to some place you can easily access to, and unzip it:

url -O http://jaist.dl.sourceforge.net/project/mysql-python/mysql-python-test/1.2.4b4/MySQL-python-1.2.4b4.tar.gz
tar -xzvf MySQL-python-1.2.4b4.tar.gz

Go into the dir you just unzipped, install it directly:

python setup.py build
python setup.py install

It should be done by now. You could check by

import MySQLdb

in the python console.


The procedure could be a little different according how you set up your EC2 instance, but the most tricky part, I believe, is installing python-devel before you install the MySQLdb.

To sum up, before you install MySQLdb, make sure you have below all intalled:

Recommended Posts

Python - Installieren Sie MySQLDB auf EC2
Installieren Sie Python auf Pidora.
Installieren Sie Scrapy auf Python3
Installieren Sie Python auf dem Mac
Installieren von Python 3 in einer Mac-Umgebung
Installieren Sie Python3.4 unter CentOS 6.6
Installieren Sie Python unter Windows
Installieren Sie Python 2.7.3 unter CentOS 5.4
Installieren Sie Python 3.3 unter Ubuntu 12.04
Installieren Sie Python 3.4 auf einem Mac
Installieren Sie Python 3.8, Pip 3.8 auf EC2 (Amazon Linux 2)
Installieren Sie Python 3.6 auf Docker
[Version 2020] So installieren Sie Python3 auf EC2 von AWS
Installieren Sie Watchdog unter Windows + Python 3.3
Installieren Sie pygame auf python3.4 auf dem Mac
Installieren Sie Python 3.8 unter CentOS 7 (SCL)
Installieren Sie pandas 0.14 auf python3.4 [auf Mac]
Installieren Sie OpenCV unter Ubuntu + Python
Installieren Sie Python 3.8 unter CentOS 8 (AppStream)
[Python] [Chainer] [Windows] Chainer unter Windows installieren
Installieren Sie Python
Installieren Sie Python Pillow unter Amazon Linux
Installieren Sie Python 3.8 unter Ubuntu 18.04 (Betriebssystemstandard)
Installieren Sie Python 3 auf dem Sakura-Server (FreeBSD)
Installieren Sie Python 3.8 unter Ubuntu 20.04 (Betriebssystemstandard)
Installieren Sie xgboost (Python-Version) unter Windows
Installieren Sie Python unter Windows + pip + virtualenv
Installieren Sie Python 3.7 Anaconda auf dem MAC, aber Python 2
Installieren Sie python3 auf einem Mac (El Capitan)
Installieren Sie Python 3.9 unter Ubuntu 20.04 (Betriebssystemstandard?)
Installieren Sie die Python-Entwicklungsumgebung unter Windows 10
Installieren Sie Python unter CentOS mit Pyenv
Installieren Sie Confluent-Kafka für Python unter Ubuntu
Installieren Sie Python 2.7 unter Ubuntu 20.04 (Betriebssystemstandard?)
Schritte zum Installieren von python3 auf einem Mac
Installieren Sie Python unter CentOS mit pyenv
Ich werde Ruby auf EC2 (Amazon Linux2) 2020 installieren
Python unter Windows
[Kivy] So installieren Sie Kivy unter Windows [Python]
Installieren Sie die Python-Bibliothek auf Lambda mit [/ tmp]
Lokale Installation von Python
Schritte zum Installieren der Python-Umgebung unter Ubuntu
Installieren Sie NAOqi Python
Python auf Mac
Installieren Sie Python unter 3.5.3 unter macOS Catalina
Installieren Sie Python Control
Installieren Sie Python auf xserver, um pip zu verwenden
Python auf Windbg
Installieren Sie Python3 auf dem Mixhost-Server [Derzeit NG]
Installieren Sie pyenv und Python 3.6.8 unter Ubuntu 18.04 LTS
CentOS8 --Installieren - Python3
Installieren Sie Python3 und Django unter Amazon Linux (EC2) und führen Sie den Webserver aus
Installieren Sie Python3.5 + NumPy + SciPy und führen Sie es unter Windows 10 aus
Installieren Sie Python3, Numpy, Pandas, Matplotlib usw. unter Windows
Erstellen Sie eine Python-Umgebung mit pyenv auf EC2 (Ubuntu)
Installieren Sie das Python-Paket in einer persönlichen Umgebung unter Ubuntu
Installieren Sie OpenCV 4.0 und Python 3.7 unter Windows 10 mit Anaconda
Python-Entwicklung unter Ubuntu unter AWS EC2 (mit Jupyter Lab)
Führen Sie die Pip-Installation unter MacOS Python 3.7 oder höher aus
Installieren Sie Python 3 unter MacOS Catalina (nur mit Homebrew)