계정생성 및 권한 부여
MySQL 사용자 생성, 권한부여, 삭제
mysql> CREATE USER 'aaaa'@'localhost' IDENTIFIED BY 'password';
mysql> GRANT ALL ON *.* TO 'aaaa'@'localhost' WITH GRANT OPTION;
mysql> GRANT ALL ON DB.TABLE TO 'aaaa'@'localhost' WITH GRANT OPTION;
mysql> GRANT ALL ON bankaccount.* TO 'aaaa'@'localhost' ;
부여된 권한 보기
mysql> SHOW GRANT FOR 'aaaa'@'localhost';
부여되지 않은 권한 보기
mysql> SET print_identified_with_as_hex=ON
mysql> SHOW CREATE USER 'aaaa'@'localhost'\G ;
권한 회수
mysql> REVOKE ALL ON *.* FROM 'aaaa'@'localhost';
부분 권한 회수
mysql> REVOKE INSERT ON *.* FROM 'aaaa'@'localhost';
계정 삭제
mysql> DROP USER 'aaaa'@'localhost';
예약된 계정 Reserved Accounts
1) 'root'@'localhost'
- 관리목적, 모든 권한을 가짐
2) 'mysql.sys'@'localhost'
3) 'mysql.session'@'localhost'
4) 'mysql.infoschema'@'localhost'
권한을 변경했을 때 영향을 끼치는 시점
mysqld server가 시작될 때 grant table의 모든 정보를 읽어서 memory 에 올려놓는다.
flush privileges 를 하게 되면 grant table의 모든 정보를 reload 하게 된다
Table and column privileges는 클라이언트의 다음 요청(client's next request)으로 영향을 받는다.
Database privileges 는 use db_name 구문이 실행이 되어야 영향을 끼친다.
Global privileges and password 는 현재 연결된 클라이언트한테는 영향을 끼치지 않으며, 다음번 연결에 영향을 끼친다.
사용자 패스워드 변경
mysql>ALTER USER 'aaaa'@'localhost' identified by 'password';
사용자 계정명 변경
mysql>RENAME USER 'aaaa'@'localhost' to 'dddd'@'localhost';