Install MySQL Server on Raspberry Pi - ajumalp/rpi-nas GitHub Wiki

sudo apt -y install mariadb-server
  • Once database is installed, we need to create a database user with password
  • To do this, run below commands 1/1
sudo mysql --user=root
DROP USER 'root'@'localhost';
CREATE USER 'root'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION;

Provide Remote Access

To provide remote access, 1st edit my.cnf file

sudo nano /etc/mysql/my.cnf

Then add below line at the end or if bind-address already exists, then change it

bind-address = 0.0.0.0

Now save the file Ctrl+X