How to Install python-mysqldb as Python Interface to MySQL in Ubuntu Linux via Command Line

Posted on

This is another article where the focus on the discussion is about the installation of MySQL Database support connection for Python programming language. Furthermore to be more specific, it is an interface provided for Python so that the connection to MySQL Database can be achieved.  The support or the interface is provided by installing a package named ‘python-mysqldb’. Below is the information about it :

root@hostname:~# apt-cache show python-mysqldb
Package: python-mysqldb
Priority: optional
Section: python
Installed-Size: 163
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Original-Maintainer: Debian Python Modules Team <python-modules-team@lists.alioth.debian.org>
Architecture: amd64
Version: 1.3.7-1build2
Provides: python2.7-mysqldb
Depends: python (<< 2.8), python (>= 2.7~), python:any (>= 2.7.5-5~), libc6 (>= 2.4), libmysqlclient20 (>= 5.7.11)
Suggests: mysql-server, python-egenix-mxdatetime, python-mysqldb-dbg
Filename: pool/main/p/python-mysqldb/python-mysqldb_1.3.7-1build2_amd64.deb
Size: 42386
MD5sum: 4b93ee8c91fda9773471c4f9b3026517
SHA1: c925bbeed0a8f11063d57d3424172349dadb2a19
SHA256: 3ca1a39e025def7283f5f5cde2e144c1793fe8bc27e844ff4ee5450db532bb07
Description-en: Python interface to MySQL
 Mysqlclient is an interface to the popular MySQL database server for Python.
 .
 This is a fork of MySQLdb. It add Python 3.3 support and merges some pull
 requests.
 .
 This package contains modules for all Python 2.x versions supported in Debian.
Description-md5: cb3fe37f0093f942d4f127716166ffcf
Homepage: https://pypi.python.org/pypi/mysqlclient
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Origin: Ubuntu
Supported: 3y                                                                                                                                                                                                                     
Task: mythbuntu-frontend, mythbuntu-frontend, mythbuntu-desktop, mythbuntu-backend-slave, mythbuntu-backend-slave, mythbuntu-backend-master, mythbuntu-backend-master                                                             
                                                                                                                                                                                                                                  
root@hostname:~# 

In the context of this article,  the installation is executed in an Ubuntu Linux distribution using ‘apt’ package management. Before installing ‘python-mysqldb’, just check it using the command of ‘apt list –installed | grep python-mysqldb’ as shown below :

user@hostname:~# apt list --installed | grep python-mysqldb

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

root@hostname:~# apt-get install python-mysqldb
Reading package lists... Done
Building dependency tree
Reading state information... Done
Suggested packages:
python-egenix-mxdatetime python-mysqldb-dbg
The following NEW packages will be installed:
python-mysqldb
0 upgraded, 1 newly installed, 0 to remove and 70 not upgraded.
Need to get 42,4 kB of archives.
After this operation, 167 kB of additional disk space will be used.
Get:1 http://us.archive.ubuntu.com/ubuntu xenial/main amd64 python-mysqldb amd64 1.3.7-1build2 [42,4 kB]
Fetched 42,4 kB in 1s (31,1 kB/s)
Selecting previously unselected package python-mysqldb.
(Reading database ... 934345 files and directories currently installed.)
Preparing to unpack .../python-mysqldb_1.3.7-1build2_amd64.deb ...
Unpacking python-mysqldb (1.3.7-1build2) ...
Setting up python-mysqldb (1.3.7-1build2) ...
root@hostname:~#

If the package has not been installed, just type ‘apt-get -y install python-mysqldb’.

Leave a Reply