The installation of MySQL onto the Raspberry Pi should be straight forward. However, there is an issue that can catch you out to do with the file system size. If there is not enough space on the SD card, the installation will fail, so you should check that first.
Check the file size on your SD card
Run the following command:
The SD card is probably 4GB. The filesystem will be around 1.9GB. This was done to make it fit on 2GB cards. To stretch the filesystem to the full size you need to run:
and choose the:
option. Then you need to reboot.
Now:
should tell you that the filesystem has much more free space.
Run the installation script below to install MySQL.
To install MySQL
If this fails and gives a message saying that it is unable to find MySQL, try installing MariaDB using the following:
To secure your MySQL installation
To further secure your MySQL installation you should use sudo mysql_secure_installation utility in your terminal.
Note that you should use sudo to run this command as it requires root privileges.
This utility does the following:
- You can set a password for root accounts.
- You can remove root accounts that are accessible from outside the local host.
- You can remove anonymous-user accounts.
- You can remove the test database (which by default can be accessed by all users, even anonymous users), and privileges that permit anyone to access databases with names that start with test_.
All you need to do is go into your terminal and type sudo mysql_secure_installation and follow the prompts.