5

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

1

3 Answers 3

9

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
Sign up to request clarification or add additional context in comments.

1 Comment

Any suggestions to make this work for a Pi 4B? I ran all the commands listed above with Python 3.11.2, pip 23.0.1 installed. It told me that package python3-mysql.connector has no installation candidate. My Pi has aarch64 architecture running Debian GNU Linux 12 (bookworm), Linux Kernel release 6.1.0-rpi6-rpi-v8, and Linux Kernel version #1 SMP PREEMPT Debian 1:6.1.58-1+rpt2 (2023-10-27).
3

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

3 Comments

How is this different from any of the other answers? What makes your command line the best?
it's answering exactly what the person requested for, I thought it's a straight forward answer for someone who might be visiting this page again. Thanks.
How does this differ substantially from the other answers? It's essentially a duplicate.
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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.