교육

MySQL 계정관리/권한관리

MorningPhys 2016. 9. 8. 13:27


계정 생성

 

  grant usage on *.* to 사용자ID@접속호스트 identified by "패스워드" 


 

localhost 에서 접속가능한 testuser 계정 생성
 

  grant usage on *.* to testuser@localhost identified by "password"


 

어디서나 접속가능한 testuser 계정 생성
 

  grant usage on *.* to testuser@"%" identified by "password"


 

권한 부여
 

  grant 각종 권한들 on 디비이름 to 사용자ID@접속호스트


 

testuser 계정에 모든 database 의 모든 테이블에 어디서나 접속가능한 권한 부여, 비밀번호는 testuser123 으로 부여
 

  grant all privileges on *.* to testuser@'%' identified by 'testuser123' with grant option


 

testuser 계정에 testdb database 의 모든 테이블에 localhost 에서만 접속가능한 권한 부여
 

  grant all privileges on testdb.* to testuser@'localhost' identified by 'testuser123' with grant option 


 

권한 삭제
 

  revoke 각종 권한들 on 디비이름.테이블 from 사용자ID@접속호스트


testuser 계정이 localhost 에서 접속 시 dbname 데이터베이스의 테이블에 대한 select, insert, update 권한을 삭제
 

  revoke select, insert, update dbname.* from testuser@localhost 


testuser 계정이 어디서나 접속 시 모든 권한 삭제
 

  revoke all on *.* from testuser@"%


권한 적용

 

  flush privileges 


 

권한 조회
 

  show grants for 사용자ID@접속호스트 

 

testuser 계정의 어디서나 접속가능한 권한 조회
 

  show grants for testuser@"%


 

암호 설정
 

  set password for 사용자ID@접속호스트 = password('new-password')

 

testuser 계정의 어디서나 접속가능한 비밀번호 변경
 

  set password for testuser@"%" = password('testuser12') 


출처 : https://www.fun25.co.kr/blog/mysql-account-privilege-query/?page=7&category=001

반응형