MySQL Connector for C and Python

By david | March 22, 2016 | C, Programming, Python, Python3

When working in Linux, I never can remember these packages and it’s hard to find this instruction set. If I’m going to make it available to me, why not make it available to you as well?

sudo apt-get install libmysqlclient-dev

You need libmysqlclient-dev to write C programs that interface with MySQL. You also need it to run Python, along with the following package for Python 2 or Python 3 respectively.

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

Of course, since you need to install libmysqlclient-dev for python-mysql.connector and python3-mysql.connector to work, you could just install them together, like this.

sudo apt-get install libmysqlclient-dev python-mysql.connector


sudo apt-get install libmysqlclient-dev python3-mysql.connector

If you want to work with C++ and MySQL:

sudo apt-get install libmysqlclient-dev
sudo apt-get install libmysqlcppconn-dev

An easy way to try and ensure you have all dependencies installed, is to ask apt to install all build dependencies for it's packaged version:

sudo apt-get build-dep libmysqlcppconn-dev

There, now I will be able to find this information when I need it. I use it for Ubuntu, Debian and Raspbian installations where I want to write custom scripts and programs to access a database.

c,.connector, debian, linux, mysql, programming, python, python3, raspbian, ubuntu