Mysql

mysql 유저 생성

뱀고기* 2015. 9. 9. 10:33

- 다른 PC에서 mysql 서버로 접속을 하기 위한 사용자 추가

 mysql> create user 'userId'@'%' identified by 'userpassword';


- 위 사용자에게 모든 것을 할 수 있는 권한 주기

mysql> grant all privileges on *.* to 'userid'@'%';


- 위 사용자에게 특정 DB를 관리할수 있는 권한 주기

 mysql> grant all privileges on dbname.* to 'userid'@'%';


- 로컬PC에서 mysql로 접속하기 위한 사용자 추가

 mysql> create user 'userId'@'localhost' identified by 'userpassword';


- 위 사용자에게 모든 것을 할 수 있는 권한 주기

 mysql> grant all privileges on *.* to 'userid'@'localhost';


- 위 사용자에게 특정 DB를 관리할 수 있는 권한 주기

 mysql> grant all privileges on dbname.* to 'userid'@'localhost';





출처:http://naleejang.tistory.com/59


사용자에게 주어진 권한 확인방법


mysql > show grants for test@localhost;

mysql > show grants for test@'%';

mysql > show grants for test@'ip명';


사용자 DB 사용권한 제거

mysql > revoke all on test.* from test@'%';


DB 유저 삭제

drop user user명@server명;

mysql > drop user user1@localhost;