DataBase/MySQL
[MySQL] 데이터 제어어 DCL: 권한부여, 권한 삭제 grant, revoke
자바칩 프라푸치노
2020. 11. 25. 19:25
1) 사용자 추가하기
1
|
create user 'abc'@'localhost' identified by '1234';
|
cs |
id: abc
password : 1234
2) 사용자 삭제하기
1
2
|
drop user 'abc'@'localhost';
|
cs |
3) 권한 부여하기
1
2
3
4
5
|
-- 모든 권한 부여하기
-- all privieges 는 모든 권한을 *.*은 모든 데이터베이스의 모든 테이블을 뜻한다.
grant all privileges on *.* to 'abc'@'localhost';
grant all privileges on sqldb.* to 'abc'@'localhost';
grant all privileges on sqldb.usertbl to 'abc'@'localhost';
|
cs |
abc에게 모든 권한 부여하기 *.*
sqldb의 모든 테이블에 모든 권한 부여하기
sqldb의 usertbl에 모든 권한 부여하기
4) 특정권한 부여하기
1
2
3
4
|
grant select on sqldb.usertbl to 'abc'@'localhost';
grant update on sqldb.usertbl to 'abc'@'localhost';
grant delete on sqldb.usertbl to 'abc'@'localhost';
|
cs |
5) 특정 컬럼만 권한 부여하기
1
|
grant update(userid, name) on sqldb.usertbl to 'abc'@'localhost';
|
cs |
6) 권한 삭제하기
1
2
3
4
5
|
-- 사용자 권한 삭제하기
-- 모든 권한이 한번에 삭제가 되지 않는다.
revoke all on *.* from abc@localhost;
-- 하나씩 권한을 삭제해야한다.
revoke select on sqldb.usertbl from abc@localhost;
|
cs |
mysql에서는 첫번째 줄 코드가 안됩니다.
하나씩 권한을 삭제해야합니다.
7) 유저의 권한 보기
1
2
|
show grants for 'abc'@'localhost';
|
cs |
728x90