-
Notifications
You must be signed in to change notification settings - Fork 0
/
topic_11_securing_database.sql
48 lines (35 loc) · 1.13 KB
/
topic_11_securing_database.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
## securing the database:
#
create user john identified by '12345'; # password
# user can connect from any computers in this domain.
create user [email protected];
create user john@localhost;
create user [email protected]; # user can connect from any computers in this domain.
create user john@'%.codewithmosh.com'; # user can connect from any computers in this domain and the subdomains.
## viewing users:
select * from mysql.user;
create user [email protected] identified by '123';
drop user [email protected];
set password for john = '1234';
# set your own password:
set password = '1234';
## granting privileges:
-- 1: web/desktop application that read and write data in database
create user moon_app identified by '1234'; # always use strong passwords
grant select, insert, update, delete, execute
on sql_store.*
# on sql_store.customers
to moon_app;
# to moon_app@****; # host/IP/domain name.
-- 2: Admin a database
grant all
on sql_store.* # *.* # all tables in all databases.
to john;
show grants for john;
## revoke privileges:
grant create view
on sql_store.*
to moon_app;
revoke create view
on sql_store.*
from moon_app;