Before performing any activity, MYSQL must be installed on the board.
Before MYSQL installation check for updates
sudo apt-get update
------------------------------------------------
Install MYSQL using the below command:
sudo apt install mariadb-server
------------------------------------------------
Create a root for accessing the database:
sudo mysql -u root -p
------------------------------------------------
Create a database:
CREATE DATABASE test_database;
------------------------------------------------
start using the database:
USE test_database;
------------------------------------------------
Create a table in the database with different fields:
CREATE TABLE studentdata (sclass TEXT, sname TEXT, smarks NUMERIC);
------------------------------------------------
Show the created table:
SHOW TABLES;
------------------------------------------------
show fields inside the table:
SHOW FIELDS from studentdata;
------------------------------------------------
insert records into the table:
INSERT INTO studentdata (sclass,sname,smarks) VALUES('DEGREE','TALENTEVE',50);
------------------------------------------------
Show all the records inside the table:
SELECT * FROM studentdata;
------------------------------------------------
Use below commands to delete a record from the table:
DELETE FROM studentdata;
DELETE FROM studentdata WHERE smarks=25
------------------------------------------------
Create a user to access the database:
CREATE USER 'tony' IDENTIFIED BY 'usertony';
Grant Privileges:
GRANT ALL PRIVILEGES ON test.* TO 'tony';
Confirm the privileges:
FLUSH PRIVILEGES;
0 Comments