I have downloaded the Connector/Python for MySQL successfully. I used the following code in Python\'s shell to test my connection:
import mysql.connector
You need to use one of the following commands. Which one depends on different-2 OS and software you have and use.
sudo easy_install mysql-python (mix os)
sudo pip install mysql-python (mix os)
sudo apt-get install python-mysqldb (Linux Ubuntu, ...)
cd /usr/ports/databases/py-MySQLdb && make install clean (FreeBSD)
yum install MySQL-python (Linux Fedora, CentOS ...)
I just moved source folder connector from folder mysql to site-packages.
And run import connector
run
pip list
to see list of packages you have installed. If it has
mysql-connector-python then that is fine.
Remember not to name your python script file as mysql.py
Use
pip3 install mysql-connector
to install the python packaged (if you are using Python 3. For Python 2 you can use pip).
just a note, I just installed mysql on an ubuntu 16.04 server. I tried different options in the following order:
sudo apt-get install python-mysqldb: Was installed correctly, but unfortunatelly python returned ImportError: No module named 'mysql'wget http://dev.mysql.com/get/Downloads/Connector-Python/mysql-connector-python_2.1.4-1ubuntu16.04_all.deb. Installed correctly with sudo dpckg -i package_name, but python returned the same error. wget http://dev.mysql.com/get/Downloads/Connector-Python/mysql-connector-python-2.1.6.tar.gz (used 2.1.4 at that time)tar -xf mysql-connector-python-2.1.6.tar.gzcd mysql-connector-python-2.1.6/sudo python3 setup.py installDid not investigate why the first two failed, might try later. Hope this helps someone.