26 Apr 2017

Raspberry Pi: Installing MySQL 5.7 on Jessie

Source code

Recently I had the need to upgrade MySQL on a Raspberry Pi running the latest standard distribution version of Jessie. I needed to use the JSON data-type as a MySQL field. My Raspberry Pi (as of Arril 2017) was running MySQL 5.5.52, but I needed 5.7+ for the JSON data-type.

I’m providing these steps to upgrade MySQL with minimal commentary. I’m assuming you have some experience with Linux!

Prepare a new directory:

cd ~
mkdir mysql
cd mysql

Download the new MySQL packages:

wget http://ftp.debian.org/debian/pool/main/m/mysql-5.7/libmysqlclient-dev_5.7.17-1_armhf.deb
wget http://ftp.debian.org/debian/pool/main/m/mysql-5.7/libmysqlclient20_5.7.17-1_armhf.deb
wget http://ftp.debian.org/debian/pool/main/m/mysql-5.7/libmysqld-dev_5.7.17-1_armhf.deb
wget http://ftp.debian.org/debian/pool/main/m/mysql-5.7/mysql-client-5.7_5.7.17-1_armhf.deb
wget http://ftp.debian.org/debian/pool/main/m/mysql-5.7/mysql-client-core-5.7_5.7.17-1_armhf.deb
wget http://ftp.debian.org/debian/pool/main/m/mysql-5.7/mysql-server-5.7_5.7.17-1_armhf.deb
wget http://ftp.debian.org/debian/pool/main/m/mysql-5.7/mysql-server-core-5.7_5.7.17-1_armhf.deb
wget http://ftp.debian.org/debian/pool/main/m/mecab/libmecab2_0.996-3.1_armhf.deb
wget http://ftp.debian.org/debian/pool/main/m/mysql-defaults/mysql-common_5.8+1.0.2_all.deb
wget http://ftp.debian.org/debian/pool/main/l/lz4/liblz4-1_0.0~r131-2+b1_armhf.deb

Install some prerequisite libraries:

sudo apt install libaio1 libaio-dev libhtml-template-perl libevent-core-2.0-5

We will need a newer gcc version for the next step, so get that:

sudo nano /etc/apt/sources.list
(change jessie to stretch)

apt-get update
apt-get install gcc-6 g++-6

sudo nano /etc/apt/sources.list
(change stretch back to jessie)

apt-get update

Install required libraries:

sudo dpkg -i libmecab2_0.996-3.1_armhf.deb
sudo dpkg -i liblz4-1_0.0~r131-2+b1_armhf.deb

Remove the old MySQL server:

sudo apt-get --purge remove mysql-server

Install the new MySQL packages:

sudo dpkg -i mysql-common_5.8+1.0.2_all.deb
sudo dpkg -i mysql-client-core-5.7_5.7.17-1_armhf.deb
sudo dpkg -i mysql-client-5.7_5.7.17-1_armhf.deb
sudo dpkg -i mysql-server-core-5.7_5.7.17-1_armhf.deb
sudo dpkg -i mysql-server-5.7_5.7.17-1_armhf.deb
sudo reboot

After a reboot, get MySQL to upgrade and rebuild all database schemas:

mysql_upgrade -u root -p --force
sudo service mysql restart

Alrighty! At this point I had a new MySQL server running that supported JSON data-types. My pre-existing databases were still intact, and phpmyadmin still worked.

Good luck! 🙂

About the Author:

Hardware and software engineer with experience in product development and building automation. Product Manager at NEX Data Management Systems, based out of Brisbane, Australia.


  1. Ken

    None of the files exist at the location given as of today:

    $ wget http://ftp.debian.org/debian/pool/main/m/mysql-5.7/libmysqlclient-dev_5.7.17-1_armhf.deb
    –2017-06-29 17:50:52– http://ftp.debian.org/debian/pool/main/m/mysql-5.7/libmysqlclient-dev_5.7.17-1_armhf.deb
    Resolving http://ftp.debian.org..., 2001:610:1908:b000::148:12
    Connecting to http://ftp.debian.org||:80… connected.
    HTTP request sent, awaiting response… 404 Not Found
    2017-06-29 17:50:53 ERROR 404: Not Found.

    How did you find them

  2. Opsse

    Well, It seem like I broke “apt” with this.

    After “Install required libraries:” part, “apt-get” command do nothing. “remove” remove nothing and “update” do nothing, no error message, just nothing.

    Any idea ?

    • Opsse

      I force the next step by removing “mysql-server” with “dpkg -r”, now “mysql_upgrade -u root -p –force” throw a nice “Segmentation fault”.

      And “apt” still doesn’t work.

      I feel like I messed up ><

  3. lbnlrnt

    Hi ! Good tuto every thing went pretty well !

    I’m pretty noob to linux world, command line and all these things

    so two things:
    -your tuto is good cause I succeed to do it
    -it will excuse me from the following question which I’m perhaps really close to the response

    The problem :

    I have now mysql 5.7 running,
    phpmyadmin is working (as you said too) but its version (under jessie / raspbian) don’t manage JSON and this is
    the thing I wanted by running 5.7 mysql.

    So far, I resolved this by using your way of pimping source.list :

    (stretch is using phpmyadmin 4.6 witch manage json …) :

    sudo nano /etc/apt/sources.list
    (change jessie to stretch)

    apt-get update
    apt-get install phpmyadmin

    sudo nano /etc/apt/sources.list
    (back to jessie..)

    Here we are, if you need it, it is perhaps the first step to get it BUT read what’s next:

    in phpmyadmin’s home page the following message is displayed (already before that in fact):

    “Your PHP MySQL library version 5.5.53 differs from your MySQL server version 5.7.18. This may cause unpredictable behavior.”

    And I don’t really know how to do that update. ( I didn’t tried in fact if it’s working or not)
    I understood, it is php plugin which is not up to date (e g MySQL Client Library ?? )

    After some search I found this, I guess it is the way:


    unfortunally in usr/bin there is no mysql_config in my rPi
    so once again, some search:


    I tried the first answer (even I was fearing breaking what I did in this tuto) :

    sudo apt-get install libmysqlclient-dev

    Haha I was fearing for nothing this does not exist anymore. and say

    but this package is remplacing :

    Now I really fearing, I don’t want to do that I’m pretty sure it will broke what we did.

    So I came back here to cry, anyone has an idea how I can do that, I mean having a mysql_config or updating

    there is a sub response to the main response in the SO post which say:

    “what you can do is you can manually download suitable mysql server precompiled version and extract mysql_config from tar.gz file. put it in your path. all it does is to read my.cnf file.”

    But I’m not sure how to do that. I thing it’s kinda what we did, “extracting”?

    So sorry for this long text and I’m pretty sure there is many misspell or mistake, I’m not English native speaker so explaining is a bit hard (even in my native language I’m bad x’) )

    I hope it is the first step to get the problem resolved, cause I thing this version of mysql would be interesting peoples for JSON support.

    Any one else has this problem?

    Hope I heard from you guys soon, if I find something new I’ll keep you in touch.

Leave a Reply