mysql 유저생성 및 권한
MYSQL에서 유저를 추가하는 방법은 두가지가 있습니다.
일반적으로는 유저를 위한 전용 데이터베이스를 하나 생성해 주고, 해당 데이터베이스에 접속할 권한을 주게 됩니다. 이 때 권한은 local에서만 접속할 권한을 주거나, JDBC등을 이용한다면 외부에서도 접속할 권한을 주어야 합니다.
1. CREATE USER와 GRANT 명령어 사용
2. INSERT, UPDATE, DELETE를 사용해서 직접 관리 테이블을 수정하기를 통한 추가
- ID:test, pass:test 란 유저 생성
mysql> create user 'test'@'localhost' identified by 'test';
↑아이디 ↑비밀번호
- 권한 위임
mysql> grant all privileges on *.* to 'test'@'localhost' identified by 'test'
↑모든DB ↑로컬에서만접속 ↑비밀번호
mysql> grant all privileges on *.* to 'test'@'%' identified by 'test' with grant option
↑원격에서 접속가능 ↑권한위임가능
mysql> grant all privileges on mydb.* to 'test'@'localhost' with grant option
↑DB지정
- 권한 보기
#show grants for 'ID'@'loalhost'
- 권한 적용
#flush privileges