Installing MySQL 5.7 in Jessie

Rutherford, North Bergen, Bergen County, NJ, NYC, New Jersey, New York, New York City, NY , Walden, Walden System, Waldensys, Ames , Ames Computer, geeks,  geek,  corner, geeks corner, hardware, how to,  MySQL, Raspberry Pi, Pi, rpi, database,  install, packages, dpkg, apt-get, repository
https://www.raspberrypi.org/

If you are running Jessie on Raspberry Pi and need to use JSON data types in MySQL, you will need to upgrade to MySQL 5.7 since the current distribution of Jessie is running MySQL 5.5. You can't just run sudo apt-get mysql since MySQL 5.7 is not in the current repo. In this article, we will go through step by step on installing MySQL 5.7 on Raspberry Pi running Jessie.

Download the MySQL files

The first thing we need to do is download the MySQL packages. We will need to create a new directory to download the MySQL packages into. Then we will need to download the packages from the Debian ftp site.


Create directory in home directory

cd ~
mkdir mysql_files
cd mysql_files


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


Install prerequisite libraries

We will need to install some prerequisite libraries. Some of the libraries can be installed from the standard repository but we will need to install a newer version of gcc that is not in the standard repositories. In order to download a newer version of gcc, we will have to edit the repository lists that Jessie looks at. In this tutorial, we will be using vi but you can use any text editor you like. After installing the newer version of gcc, we will change the repository list back to the default. Here are the steps for installing the libraries :

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


Edit repository list
sudo vi /etc/apt/sources.list

Change all occurrences of jessie to stretch and then save the file.

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


Reset repository list
sudo vi /etc/apt/sources.list

Change all occurrences of stretch back to jessie and then save the file.

Uninstall old MySQL and install new MySQL

Before we can install MySQL 5.7, we must uninstall the MySQL 5.5 ( if it was installed ). Once the old MySQL is uninstalled, we will install the packages we downloaded earlier. Once that is done, all that is left to do is reboot the Raspberry Pi.

Install required libraries

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


Remove the old MySQL
sudo apt-get --purge remove mysql-server


Install the new MySQL packages
sudo dpkg -i mysql-common_5.8+1.0.4_all.deb
sudo dpkg -i mysql-client-core-5.7_5.7.21-1_armhf.deb
sudo dpkg -i mysql-client-5.7_5.7.21-1_armhf.deb
sudo dpkg -i mysql-server-core-5.7_5.7.21-1_armhf.deb
sudo dpkg -i mysql-server-5.7_5.7.21-1_armhf.deb


Reboot Raspberry Pi
sudo reboot

Once the Raspberry Pi is rebooted, you will have the new version of MySQL installed which supports JSON data types. If you ever have to install packages for Raspberry Pi and the packages doesn't exist in the default repositories, you don't have to give up. The difficult part of updating or installing packages that are not in the standard repositories is finding the packages and getting their dependencies. Once that is done, it is just a matter of a few simple steps.