서버관련

[mysql] 권한 관리

Dohoon 2015. 2. 23. 17:30

무료에 사용하기 쉽고(?) 참고할 내용도 구글님에 많고
그래서 너무나 사랑하는 DBMS
그 이름  

M Y S Q L

물론 깊게 들어가면 죽음 이지만....

여튼 mysql 설치야 yum을 사용하면 너무 간단하니 패스하고

가장 기본이면서 ~
가장 중요하지만 ~
자주 안 써서 기억에서 사라지는 ~
그래서 맨날 구글님께 물어보는 ~ !!
접속 권한 관련 내용을 정리하기로 했다.


1. 설정
grant all privileges on 디비명.테이블명 to 아이디@'접속 서버 IP' identified by '패스워드' (with grant option);

ex ) 
grant all privileges on *.* to  root@'%' identified by '패스워드with grant option;
grant all privileges on *.* to  root@'localhost' identified by '패스워드with grant option;

2. 제거
revoke all on 디비명.테이블명 from 아이디;

3. 적용 (설정, 제거 등의 명령어 실행 후 
실제로 적용시 사용 )
flush privileges;


EX)
1. grant all privileges on testdb.tb1 to serviceid@'localhost' identified by 'pw1111';
< serviceid 계정은 testdb 디비의 tb1 테이블에 localhost 에서만 접속 가능>

2. grant all privileges on testdb.* to serviceid@'123.456.789.%' identified by 'pw1111';
< serviceid 계정은 testdb 디비의 모든 테이블에 123.456.789 ipi 대역에서만 접속 가능>

3. grant all privileges on *.* to serviceid@'%' identified by 'pw1111';
< serviceid 계정은 모든 디비의 모든 테이블에 모든 ip 에서 접속 가능 >


3번으로 설정하면 이런 날이 올 수도 있습니다 .엉엉