installing mysql connector for python 3 in raspberry pi

29,971

Solution 1

I found no way to install mysql-connector-python that I used with windows. for python 3.4 I used the command

sudo python3 -m pip install pymysql

for python 2.7 you can use following commands

 sudo apt-get install python-mysqldb

or

sudo apt-get install python-pip
pip install pymysql

Solution 2

Before you install, it is important to run update and upgrade;

sudo apt-get update
sudo apt-get upgrade

Either install connector for Python 2;

sudo apt-get -y install python-mysql.connector

Or install connector for Python 3;

sudo apt-get -y install python3-mysql.connector

Solution 3

Just use $sudo apt-get install python3-mysqldb and it works on pi-3.

Share:
29,971
M2skills
Author by

M2skills

I love coding , I like teaching others what I know and at the same time learn from others. I know c, c++ , python , java and web development. I am interested in artificial intelligence , big data analysis , android development.

Updated on July 09, 2022

Comments

  • M2skills
    M2skills almost 2 years

    I am new at using raspberry pi. I have a python 3.4 program that connects to a database on hostinger server. I want to install mysql connector in raspberry pi.I searched a lot but I was not able to find answers . any help would be appreciated