Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Experiment No: 10

Case study of Oracle Database Administration, Security & Study of database


administrator's responsibilities.

To grant a privilege:
GRANT type_of_permission ON database_name.table_name TO ‘username’@'localhost’; To
revoke a privilege:

REVOKE type_of_permission ON database_name.table_name FROM ‘username’@‘localhost’;


e.g.

mysql> create user 'Ram'@'localhost' identified by 'ram'; mysql>


GRANT ALL PRIVILEGES ON * . * TO 'Ram'@'localhost';

//mysql> DROP USER ‘username’@‘localhost’;//remove user

mysql> create user 'Sita'@'localhost' identified by 'sita'; mysql>


grant select on sbp1.customer to 'Sita'@'localhost'; mysql>
grant select on sbp1.account to 'Sita'@'localhost';

Open new terminal and do following steps:


ubuntu@ubuntu-OptiPlex-3020:~$ mysql -u Sita -p
Enter password: mysql> use sbp1; Database
changed mysql> select * from customer;

+-------------+---------------+-----------------+---------------+
| customer_id | customer_name | customer_street | customer_city |
+-------------+---------------+-----------------+---------------+
| 1 | Ram | Main | Kolhapur |
| 2 | Sachin | Station | Pune |
| 3 | Sourabh | MG | Mumbai |
| 100 | Seeta | Main | Kolhapur |
+-------------+---------------+-----------------+---------------+
4 rows in set (0.00 sec)

mysql> select * from account;


ERROR 1142 (42000): SELECT command denied to user 'Sita'@'localhost' for table 'account'
mysql> select * from account;

+----------------+-------------+---------+
| account_number | branch_name | balance |
+----------------+-------------+---------+
| 101 | sbi bvcoek | -500 |
| 102 | ubi bvcoek | 1000 |
+----------------+-------------+---------+
2 rows in set (0.00 sec)

mysql> show grants;


+-----------------------------------------------------------+
| Grants for Sita@localhost |
+-----------------------------------------------------------+
| GRANT USAGE ON *.* TO 'Sita'@'localhost' |
| GRANT SELECT ON `sbp1`.`customer` TO 'Sita'@'localhost' |
| GRANT SELECT ON `sbp1`.`account` TO 'Sita'@'localhost' |
+-----------------------------------------------------------+
3 rows in set (0.00 sec)

You might also like