Install MySQL Connector/Python on CentOS

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
  Downloading https://files.pythonhosted.org/packages/d8/29/...
Collecting dnspython==1.16.0 (from mysql-connector-python)
  Downloading https://files.pythonhosted.org/packages/ec/d3/...
Collecting protobuf==3.6.1 (from mysql-connector-python)
  Downloading https://files.pythonhosted.org/packages/c2/f9/...
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 https://dev.mysql.com/downloads/connector/python/ 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 https://dev.mysql.com/doc/connector-python/en/ to learn more.

Table of Contents

 About This Book

 Introduction to Linux Systems

 Cockpit - Web Portal for Administrator

 Process Management

 Files and Directories

 Users and Groups

 File Systems

 Block Devices and Partitions

 LVM (Logical Volume Manager)

 Installing CentOS

 SELinux - Security-Enhanced Linux

 Network Connection on CentOS

 Software Package Manager on CentOS - DNF and YUM

 Running Apache Web Server (httpd) 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

 vsftpd - Very Secure FTP Daemon

 Postfix - Mail Transport Agent (MTA)

 Dovecot - IMAP and POP3 Server

 Email Client Tools - Mail User Agents (MUA)

 LDAP (Lightweight Directory Access Protocol)

 GCC - C/C++ Compiler

 Conda - Environment and Package Manager

 Tools and Utilities

 Administrative Tasks

 References

 Full Version in PDF/EPUB