Install MariaDB server
As said in the introduction, MariaDB is available in the Raspberry Pi OS repository, so the installation is straightforward. Open a terminal (or connect via SSH) and follow the instructions:
- As always, start by updating your system:
sudo apt update
sudo apt upgrade
- Then you can install MariaDB with this command:
sudo apt install mariadb-server
- Type “Y” and Enter to continue.
After a few seconds, the installation process is complete and MariaDB is almost ready to use.
If you’ve noticed it, the installation of MariaDB has also installed the MariaDB client.
This will allow you to connect from the command line with:
mysql
Root access
Here is how to define the password for the root user and start to use MariaDB:
- Enter this command:
sudo mysql_secure_installation
- Press enter to continue (no password by default).
- Press “Y” to switch to unix_socket authentication.
- Then type “Y” to set a new password, and enter the password of your choice.
- Now, press “Y” three more times
- Remove anonymous users.
- Disallow root login remotely.
- Remove the test database.
- And finally, press “Y” again to reload the privileges.