Install MySQL Connector/Python on CentOS

This section provides a tutorial example on how to install MySQL Connector/Python on CentOS systems.

If you want to access MySQL database server from Python scripts, you can follow what I did on my CentOS 8 computer to install the MySQL Connector/Python module.

1. Install MySQL Connector/Python with "pip3" command.

herong$ sudo pip3 install mysql-connector-python

Collecting mysql-connector-python
Collecting dnspython==1.16.0 (from mysql-connector-python)
Collecting protobuf==3.6.1 (from mysql-connector-python)
Requirement already satisfied: six>=1.9 ...
Requirement already satisfied: setuptools ...
Installing collected packages: dnspython, protobuf, mysql-connector-python
  Found existing installation: protobuf 3.11.3
  Successfully uninstalled protobuf-3.11.3
Successfully installed
  dnspython-1.16.0 mysql-connector-python-8.0.19 protobuf-3.6.1

2. If "pip3" command fails, install MySQL Connector/Python with "dnf/yum" command.

herong$ sudo yum install mysql-connector-python

3. If "dnf/yum" command fails, Go to MySQL Connector/Python download Web site at to download the "Red Hat Enterprise Linux 8 / Oracle Linux 8 (x86, 64-bit), RPM Package". Then run the "rpm" command to install it.

herong$ sudo rpm -i ....rpm

4. Test MySQL Connector/Python with the following Python code:

herong$ python3
>>> import mysql.connector
>>> con = mysql.connector.connect(
  user='herong', password='TopSecret', host='localhost')
>>> con.close()

5. Read the MySQL Connector/Python Developer Guide at to learn more.

Table of Contents

 About This Book

 Introduction to Linux Systems

 Process Management

 Files and Directories

 Running Apache HTTP Server (httpd) on Linux Systems

 Running Apache Tomcat on Linux Systems

 Running PHP Scripts on Linux Systems

 Running MySQL Database Server on Linux Systems

Running Python Scripts on Linux Systems

 Install and Manage Python Engine on CentOS

 "pip/pip3" Python Package Manager

Install MySQL Connector/Python on CentOS

 Install Python 2 Engine on CentOS

 Conda - Environment and Package Manager

 GCC - C/C++ Compiler

 OpenJDK - Open-Source JDK

 Graphics Environments on Linux

 SquirrelMail - Webmail in PHP

 Tools and Utilities


 Full Version in PDF/EPUB