Installing MySQL on Raspberry Pi

When installing MySQL onto a Raspberry Pi, you may receive an error which can be very difficult to identify. The installation may fail and the MySQL server will not start.

This could be an issue to do with the SD card file system free space.

You start with the Raspbian image on the SD card and boot up the Raspberry Pi.

To install MySQL when connected to the internet, in the terminal display you then enter:

sudo apt-get install mysql-server mysql-client php5-mysql

It is this command that can fail.

If you do the command:

df -h

You will see the file system free space and you may notice that the free space has not been fully allocated and that there is not enough disk space for installing the MySQL.

To expand the file system to use all the available free space run:

sudo raspi-config

then choose the expand roots option and then reboot.

If you now run:

df -h

you should see that all available space has been made available.

Now when you install MySQL it should install correctly.

It may be necessary to completely remove the existing MySQL installation using the following before you re-install:

sudo service mysql stop #or mysqld
sudo killall -9 mysql
sudo killall -9 mysqld
sudo apt-get remove –purge mysql-server mysql-client mysql-common
sudo apt-get autoremove
sudo apt-get autoclean
sudo deluser mysql
sudo rm -rf /var/lib/mysql
sudo apt-get purge mysql-server-core-5.5
sudo apt-get purge mysql-client-core-5.5

At the end of the installation you should run mysql_secure_installation command to secure the installation.

For further information on this, refer to web site slicethepi.co.uk Installing MySQL on a Raspberry Pi