Upgrading MySQL to Version 5.6 or Higher on Raspberry Pi (Raspbian ARM)
Upgrade your MySQL server from version 5.5 to 5.6 or higher on your Raspberry Pi running Raspbian, even if the official apt-get repository doesn’t support it for the ARM architecture. This guide will walk you through compiling and installing a custom MySQL build.
Current State: Unmet Dependencies
You’re currently unable to upgrade MySQL via apt-get because the official Debian Jessie repository doesn’t provide a package for MySQL 5.6 or higher on ARM architectures like your Raspberry Pi’s Broadcom BCM2710 SoC. The error message likely shows unmet dependencies that can’t be resolved.
Step 1: Install Required Dependencies
Open a terminal and run the following commands to install necessary tools:
sudo apt-get update
sudo apt-get install -y cmake g++ build-essential libreadline6-dev zlib1g-dev libssl-dev libmysqlclient-dev
These dependencies include CMake, g++, GCC compiler suite, readline development libraries, zlib development libraries, OpenSSL development libraries, and MySQL client development libraries.
Step 2: Download the MySQL Source
Download the MySQL source code for the version you need (5.6 or higher) from the official MySQL download site.
For example, to download MySQL 5.7:
wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.30.tar.gz
Step 3: Extract the Source
Extract the downloaded archive with tar:
tar -xvf mysql-5.7.30.tar.gz
cd mysql-5.7.30
Step 4: Configure and Compile MySQL
Configure the build with CMake:
cmake -DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DDOWNLOAD_BOOST=1 \
-DDOWNLOAD_LIBZLIB=1 \
-DDOWNLOAD_LIBREADLINE=1 \
-DDOWNLOAD_LIBSSL=1
Then compile the MySQL server:
make
Step 5: Install MySQL
Stop any currently running MySQL processes:
sudo systemctl stop mysql
Remove existing data directories:
sudo rm -rf /var/lib/mysql/*
Install the compiled MySQL binaries and data files:
sudo make install
Step 6: Initialize the Database
Initialize a new MySQL database:
sudo mysql_install_db --basedir=/usr/local/mysql --datadir=/var/lib/mysql
Create an my.cnf configuration file at /etc/my.cnf:
sudo nano /etc/my.cnf
Add the following content to this file:
[mysqld]
user=mysql
pid-file=/var/run/mysqld/mysqld.pid
socket=/var/run/mysqld/mysqld.sock
port=3306
basedir=/usr/local/mysql
datadir=/var/lib/mysql
tmpdir=/tmp
lc-messages-dir=./share
skip-external-locking
[client]
port=3306
socket=/var/run/mysqld/mysqld.sock
# Remove leading dot to enable MySQL to read this file from anywhere
!includedir /etc/mysql/conf.d/
Step 7: Start the MySQL Server
Start the MySQL server:
sudo service mysql start
Verify that the new version is running by querying the version number:
mysql -V
You should see output displaying the installed version (e.g., Ver 5.7.30).
Conclusion: Compiling Custom MySQL Builds
Compiling and installing a custom MySQL build from source is the only way to upgrade beyond the version supported by the official Raspberry Pi repositories. The process involves downloading, configuring, compiling, and installing the new binaries.
At Laravel Company, we specialize in helping businesses optimize their database performance with tailored MySQL solutions, even on resource-constrained systems like the Raspberry Pi.
Don’t hesitate to reach out if you need further assistance optimizing your MySQL installations or have other questions about server-side development.