How to install a MySQL Server on a Raspberry Pi
This blog post explains the steps you need to perform to install a MySQL server on a Raspberry Pi.
Ensuring the Raspberry Pi is up to date
Before installing any programs it is recommended to make sure your Raspberry Pi is up to date. This reduces the change of a conflict occurring when installing new packages.
You can do this easily enough by running the following two commands.
sudo apt update sudo apt upgrade
Once this has been done you should now be able to install a MySQL server
Installing a MySQL Server
For the Raspberry Pi the default MySQL server in the repositories is MariaDB.
This can be installed by the following command.
sudo apt install mariadb-server
Once installed your server will be ready to use, but it is recommened to perform run the secure installation command.
Securing your MySQL installation
Various MySQL distributions provide a script which allows you to improve the basic security of your MySQL server after installing it.
This can be run with the following command:
sudo mysql_secure_installation
During running the command it will offer you the ability to do the following, it is recommended to perform every step offered:
- Change the default root password (from no password)
- Remove anonymous users
- Disallow remote root login
- Remove the test database
- Reload the privilege tables
Once this has been done you are ready to start using your database.