본문 바로가기

미분류

[박혜웅] MySQL 접근 권한 설정 (Grant, Revoke 명령)

<권한설정>
grant all privileges on 디비명.테이블명 to 사용자@'접속지 주소' identified by '암호' (with grant option);

grant all privileges on *.* to  root@'%' identified by '암호with grant option;
grant all privileges on *.* to  root@'localhost' identified by '암호with grant option;

<권한 제거>
revoke all on 디비명.테이블명 from 사용자;

<권한 적용>
# 모든 명령 후에 항상 아래 명령을 실행해야 실제로 적용된다. 
flush privileges; 



<기타>
# '사용자'가 '암호'으로 111.222.333.0/24 에서 모든 디비와 테이블에 접속하도록 허용
grant all privileges on *.* to  사용자 @'111.222.333.%' identified by '암호';

# '사용자'가 '암호'으로 111.222.333.444 에서 db1 디비의 모든 테이블에 접속하도록 허용
grant all privileges on db1.* to 사용자@'111.222.333.444' identified by '암호';

# '사용자'가 '암호'으로  localhost 에서 db1 디비의 table1에 접속하도록 허용
grant all privileges on db1.table1 to 사용자@'localhost' identified by '암호';