Install MySQL Connector/Python with "pip"

This section provides a tutorial example on how to install MySQL Connector/Python package with 'pip' command.

As "pip install" command example, let's install the MySQL Connector/Python package to access MySQL database server from Python scripts.

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

herong$ sudo pip 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 "pip" 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$ python
>>> 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

 Running Python Code Online

 Python on macOS Computers

 Python on Linux Computers

 Built-in Data Types

 Variables, Operations and Expressions

 Statements - Execution Units

 Function Statement and Function Call

 Iterators, Generators and List Comprehensions

 Classes and Instances

 Modules and Module Files

 Packages and Package Directories

 "sys" and "os" Modules

 "pathlib" - Object-Oriented Filesystem Paths

"pip" - Package Installer for Python

 What Is "pip/pip2/pip3" Command

 Use "pip" Package in Python Script

Install MySQL Connector/Python with "pip"

 Using "pip" with Different Sources

 Commonly Used Python Packages/Libraries

 SciPy.org - Python Libraries for Science

 pandas - Data Analysis and Manipulation

 Anaconda - Python Environment Manager

 Jupyter Notebook and JupyterLab

 References

 Full Version in PDF/EPUB