프로그래밍 2008/02/27 14:42

DB 계정추가와 권한부여

1. 먼저 mysql 서버에 root권한으로 접속
mysql -uroot -p*****

create database if not exists tempDB;
  ::DB 생성

2. 모든 권한 부여하기
grant all privileges on *.* to tempUser@localhost identified by 'tempPassword' with grant option;

  :: 권한을 부여할때 grant 명령어나 insert 문이용 / grant 문은 flush privileges를 할 필요가 없음.
  :: localhost의 tempUser  에게 'tempPassword' 라는 암호로 모든 권한 부여

use mysql;
insert into user values('localhost','tempUser',password('tempPassword','y','y','y','y','y','y','y','y','y','y','y','y','y','y'));
flush privileges;


3. DB의 모든 테이블 권한 부여하기.
grant all privileges on tempDB.* to tempUser@localhost identified by 'tempPassword';

4. select, insert 권한만 주기.
grant select, insert on tempDB.* to tempUser@localhost identified by 'tempPassword';

5. DB테이블의 특정칼럼에 특정권한부여
grant update(name,age,email) on tempDB.testTable to tempUser@localhost identified by 'tempPassword';
  :: tempDB 데이터베이스의 testTable 테이블의 name, age, email 칼럼에 update 권한부여

6. 여러호스트에서 로그인할경우
grant select on tempDB.* to tempUser@'%' identified by 'tempPassword';

7. 특정 아이피주소에서 로그인 할 경우
grant all privileges on *.* to tempUser@'192.168.0.%' identified by 'tempPassword';


//---------------------------------
사용자 계정에 대한 관리는 mysql database 에서 합니다.
mysql>use mysql;
후에 user와 db 테이블에 원하는 정보를 입력.

from.......................
 http://blog.naver.com/platanuslkm/20028543162