권한 부여

inhalin·2021년 5월 14일
0

MySQL

목록 보기
5/8

권한 부여

// user1에게

//test_db의 test_table에 대한 권한 부여
mysql > grant all privileges on test_db.test_table to user1@host;

// test_db의 모든 테이블에 대한 권한 부여
mysql> grant all privileges on test_db.* to user1@localhost;

// 'with grant option' -> 사용자 제어 권한 부여
mysql> grant all privileges on test_db.* to user1@localhost with grant option;

// 비밀번호 변경과 동시에 권한 부여
mysql> grant all privileges on test_db.* to user1@localhost identified by 'asdf';

//모든 원격지에서 접속 권한 부여
mysql > grant all privileges on test_db.* to user1@'%' identified by 'asdf';

// select, insert, update 권한 부여
mysql> grant select, insert, update on test_db.* to user1@localhost;

// !주의
// 전역 권한 부여시 보안문제가 있을 수 있으므로 신중해야 함
mysql> grant all privileges on *.* to user1@localhost identified by 'asdf' with grant option;

// 변경 내용 반영
mysql > flush privileges;

변경 사항 확인

mysql > SHOW GRANTS FOR user1@localhost;
+------------------------------------------------------------------------------+
| Grants for inhalin@localhost                                                 |
+------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO `user1`@`localhost`                                    |
| GRANT ALL PRIVILEGES ON `test_db`.* TO `user1`@`localhost` WITH GRANT OPTION |
+------------------------------------------------------------------------------+

권한 제거

mysql> revoke all on test_db.* from user1;

0개의 댓글