Install mysql-connector-python package to Python 2.7 installed on CentOS and connect to MySQL / MarriaDB.
It can also be used with Python 3 series.
Install the connector that connects the database (MySQL, MariaDB) to python 2.7 which is installed as a standard on CentOS (7.4.1708).
Install using pip command
Install using pip command which is package management of python.
pip install mysql-connector
I failed. The error contents are as follows.
running install Not Installing MySQL C Extension running build # Python architecture: 64-bit # Python ARCH_64BIT: True Unable to find Protobuf include directory. ' ---------------------------------------- Command "/usr/bin/python2 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-eUfgeL/mysql-connector/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-HBetzs-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-eUfgeL/mysql-connector/
ERROR code 1 is returned by installing the pip command. When I looked at the MySQL site there seems to be a manual installation method.
I decided to change the installation method to manual.
yum install mysql-connector-python
For the installation method, refer to the document of the MySQL website.
Check with the pip command.
pip list backports.ssl-match-hostname (188.8.131.52) certifi (2017.4.17) chardet (3.0.4) configobj (4.7.2) decorator (3.4.0) idna (2.5) iniparse (0.4) kitchen (1.1.1) mysql-connector-python (1.1.6) ...
python -c 'import mysql.connector'
If it is executed and nothing is displayed on the standard output, it is working normally.