[MYSQL] 새로운 사용자 생성, 권한 부여, 권한 삭제
root 계정으로 로그인 한 후 다음의 작업을 수행 할 수 있다.
$ mysql -uroot -p
사용자 생성
$ create user 'username'@'localhost' identified by 'password';
사용자 권한 부여
- 사용자에게 모든 권한을 부여
$ grant all privileges on *.* to 'username'@'localhost';
- 사용자에게 특정 DB에 대한 모든 권한을 부여
$ grant all privileges on dbname.* to 'username'@'localhost';
- 사용자에게 특정 DB의 특정 테이블에 대한 모든 권한 부여
$ grant all privileges on dbname.tablename to 'username'@'localhost';
+) 사용자에게 특정한 권한만을 부여 할 수도 있다.
$ grant delete, insert, select on dbname.* to 'username'@'localhost' identified by 'password';
사용자에게 주어진 권한 확인
$ show grants for 'username'@'localhost';
사용자 권한 삭제
- 사용자에게 주어진 권한 삭제
$ revoke all privileges on dbname.tablename from 'username';
+) 모든 IP를 특정하지 않기 위해서는 'localhost' 대신 '%'를 사용한다.
$ create user 'username'@'%' identified by 'password';
사용자 삭제
$ drop user 'username'@'localhost';