You are on page 1of 5

Nama : Rendy Irawan

NPM : 192350150
Kelas : II – 3 Pagi

Microsoft Windows [Version 10.0.19043.1021]


(c) Microsoft Corporation. All rights reserved.

C:\Users\HP>cd\

C:\>cd\xampp\mysql\bin

C:\xampp\mysql\bin>mysql -u root
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 12
Server version: 10.4.19-MariaDB mariadb.org binary distribution

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input
statement.

• Buat database db_siswa


MariaDB [(none)]> create database db_siswa;
Query OK, 1 row affected (0.001 sec)

MariaDB [(none)]> use db_siswa;


Database changed

• Buat 2 tabel dalam db_siswa : tbl_siswa & tbl_operator


MariaDB [db_siswa]> create table tbl_siswa
-> (NPM varchar(255),
-> Nama varchar(255),
-> Jurusan varchar(255));
Query OK, 0 rows affected (0.297 sec)

MariaDB [db_siswa]> desc tbl_siswa;


+---------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------+--------------+------+-----+---------+-------+
| NPM | varchar(255) | YES | | NULL | |
| Nama | varchar(255) | YES | | NULL | |
| Jurusan | varchar(255) | YES | | NULL | |
+---------+--------------+------+-----+---------+-------+
3 rows in set (0.195 sec)

MariaDB [db_siswa]> create table tbl_operator


-> (NIK varchar(255),
-> Nama varchar(255),
-> Jabatan varchar(255));
Query OK, 0 rows affected (0.251 sec)

MariaDB [db_siswa]> desc tbl_operator;


+---------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------+--------------+------+-----+---------+-------+
| NIK | varchar(255) | YES | | NULL | |
| Nama | varchar(255) | YES | | NULL | |
| Jabatan | varchar(255) | YES | | NULL | |
+---------+--------------+------+-----+---------+-------+
3 rows in set (0.051 sec)

• Buat dua buah user Operator dan Admin


MariaDB [db_siswa]> create user 'operator'@'localhost';
Query OK, 0 rows affected (0.022 sec)
MariaDB [db_siswa]> create user 'admin'@'localhost';
Query OK, 0 rows affected (0.040 sec)

• Mencoba Masuk ke user Operator dan Admin


MariaDB [db_siswa]> quit
Bye

C:\xampp\mysql\bin>mysql -u operator
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 15
Server version: 10.4.19-MariaDB mariadb.org binary distribution

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input
statement.

MariaDB [(none)]> quit


Bye

C:\xampp\mysql\bin>mysql -u admin
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 16
Server version: 10.4.19-MariaDB mariadb.org binary distribution

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input
statement.

MariaDB [(none)]> quit


Bye

C:\xampp\mysql\bin>mysql -u root
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 17
Server version: 10.4.19-MariaDB mariadb.org binary distribution

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input
statement.

MariaDB [(none)]> use db_siswa;


Database changed

• Set hak akses Insert, Delete, Edit(Create) pada akses user operator
di tbl_siswa
MariaDB [db_siswa]> grant insert,delete,create on tbl_siswa to
'operator'@'localhost';
Query OK, 0 rows affected (0.021 sec)

• Set hak akses Update pada akses user operator di tbl_operator

MariaDB [db_siswa]> grant update on db_siswa.tbl_operator to


'operator'@'localhost';
Query OK, 0 rows affected (0.029 sec)
MariaDB [db_siswa]> show grants for 'operator'@'localhost';

+-------------------------------------------------------------------------
-----------------+
| Grants for operator@localhost
|

+-------------------------------------------------------------------------
-----------------+

| GRANT USAGE ON *.* TO `operator`@`localhost`


|
| GRANT INSERT, DELETE, CREATE ON `db_siswa`.`tbl_siswa` TO
`operator`@`localhost` |
| GRANT UPDATE ON `db_siswa`.`tbl_operator` TO `operator`@`localhost`
|
+-------------------------------------------------------------------------
-----------------+
3 rows in set (0.000 sec)

• Set hak akses Semua Operasi pada akses user Admin di tbl_siswa dan
tbl_operator

MariaDB [db_siswa]> grant all on db_siswa.tbl_siswa to


'admin'@'localhost';
Query OK, 0 rows affected (0.029 sec)

MariaDB [db_siswa]> grant all on db_siswa.tbl_operator to


'admin'@'localhost';
Query OK, 0 rows affected (0.030 sec)

MariaDB [db_siswa]> show grants for 'admin'@'localhost';

+-------------------------------------------------------------------------
-+
| Grants for admin@localhost
|

+-------------------------------------------------------------------------
-+
| GRANT USAGE ON *.* TO `admin`@`localhost`
|
| GRANT ALL PRIVILEGES ON `db_siswa`.`tbl_siswa` TO `admin`@`localhost`
|
| GRANT ALL PRIVILEGES ON `db_siswa`.`tbl_operator` TO `admin`@`localhost`
|

+-------------------------------------------------------------------------
-+
3 rows in set (0.010 sec)

MariaDB [db_siswa]> exit


Bye
C:\xampp\mysql\bin> exit

You might also like