How to setup MYSQL on a Raspberry Pi ?

Credit to this website:

Raspberry Pi: Install Apache + MySQL + PHP (LAMP Server)

Credit to this website: https://pimylifeup.com/raspberry-pi-mysql/

The popular relational database management system (RDMS) is MySQL and is a common inclusion in most LAMP ( Linux, Apache, MYSQL, and PHP) stacks.

Step 1 : We need to update our package list and all installed packages.

sudo apt update

sudo apt upgrade

Step 2 : Install the MySQL server software to your Raspberry Pi

sudo apt install mariadb-server php-mysql -y

or

sudo apt install mariadb-server

** In Raspbian, the mariadb is known as MySQL.

Step 3 : Restart the apache

sudo service apache2 restart

With the MySQL server software installed to the Raspberry Pi, we will now need to secure it by setting a password for the “root” user.

Step 4 : Now if you want to access your Raspberry Pi’s MySQL server and start making changes to your databases, you can enter the following command.

sudo mysql -u root -p

** If you don’t set the password, just press the ENTER.

Step 5 : You can now enter MYSQL commands to create, alter, and delete databases. Through this interface, you can also create or delete users and assign them the rights to manage any database

Step 6: To quit out of the MYSQL command line, the first of those is to type “quit”  or type Ctrl + D.

Step 7: End. You have successfully setup MySQL on your Raspberry Pi.

Login using phpMyAdmin

In a browser, type this:

http://localhost/phpmyadmin/index.php