How to install MySQL database on raspberry pi
What you will learn here about MYSQL database installation on raspberry pi
- How to install MYSQL database on raspberry pi
- How to connect MySQL database using Java on raspberry
How to install MYSQL database on raspberry pi
Please follow the following steps to know how to install MYSQL server on raspberry pi or to know how to install MariaDB server on raspberry pi.
1)Please open the raspberry pi terminal.
2)Execute the following command to update the existing packages.
3)Now execute the following to install MySQL server which is shown below. While installing if it is asking do you want to continue then please enter y and hit enter
4)Now please execute the following command for secure installation which is shown below.
5)Please hit Enter for current root password.
6)Now please Enter y and hit Enter for setting a new password which is shown below
7)Now Please enter New password which is shown below
8)Now please enter y to remove anonymous user and hit Enter.
9)Now please enter y to disallow remote login which is shown below
10)Please enter y to remove test databases which is shown below
11)Please enter y to reload privileges tables which is shown below
12)Now please execute the following command to login into the database and Enter the password which you have entered in step 7.
13)Please execute the following command to see databases present in the mysql database.
14)Execute the following to create Demo database in mysql server which is shown below.
15)Now please execute the following to go in Demo database
16)Please execute the following command to create database user
17)Execute the following command to grant all previleges
18)Now execute the following command save all the changes
19)Now please execute the following command to come out of database.
20)Execute the following command to restart the MYSQL server
How to insert and fetch data from MySQL database
Please follow the following steps to insert and fetch from the MySQL database.
1)Open the raspberry pi terminal
2)Execute the following command to login to the database and enter the password which is shown below.
3)Execute the following command to use Demo database which is shown above.
4)Execute the following command to create login table which has two coloums i.e is username and password which is shown above.
5)Execute the following command to insert data into login table which is shown below.
6)To see the inserted values please execute the following command which is shown below
How to connect MySQL server using Java on raspberry
Please download the following java project code to connect with MySQL database using java on raspberry pi.
IMPORTANT NOTE: The following code will only work if you have followed all the above steps successfully.
Download mysql connect using java code (799 downloads)