Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ansible Installing Python Mysql Connector

I'm using Ansible to automate the tasks to backup a mysql database and when running the mysql_db tasks I'm getting this message: msg: the python mysqldb module is required

So, after to many attempts to install python-mysqldb using Ansible tasks I've tried to install it manually executing the command sudo apt-get install python-mysqldb and I got the following error message:

Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package python-mysqldb

I'm using Ubuntu 13.04 64bits

What am I doing wrong?

What's the way to install python-mysqldb using apt-get?

like image 305
Lt. Avatar asked Nov 03 '14 15:11

Lt.


People also ask

Can you connect MySQL to Python?

Python needs a MySQL driver to access the MySQL database. In this tutorial we will use the driver "MySQL Connector". We recommend that you use PIP to install "MySQL Connector".

Can Ansible install Python on remote host?

Fortunately, it is possible to use Ansible to install Python on our server even when it actually depends on it — Ansible provides the raw module which can run basic low-down SSH commands on our server even if Python is not available.


1 Answers

Ubuntu 13.04 has been end-of-lifed for about 10 months. As the link says, "No more package updates will be accepted to 13.04". You should use Ubuntu 12.04 or Ubuntu 14.04, which are LTS (long-term support) versions.

Still, for this specific problem, as @phantom said, use pip.

- pip: name=MySQL-python

(note the capitalization)

like image 97
tedder42 Avatar answered Oct 05 '22 23:10

tedder42