Mysql이 설치가 되어 있다고 가정 한다.

Step 1. 데이터베이스 생성

 생성할 사용자가 사용하는 데이터베이스를 생성 한다. 생성시 명시를 해줘야 하기 때문에 먼저 작업 한다.

 create database if not exists [데이터베이스 명]

 create database if not exists whitelife;


 Step 2. 사용자 생성

 사용자를 생성 한다. 접속을 허용할 IP를 whitelife@IP 작성 하거나 '%' 모든 접속이 허용 된다.

 grant usage on [데이터베이스 명].* to [사용자 명]@[호스트] indentified by [비밀번호];

grant usage on whitelife.* to whitelife@localhost identified by 'whitelife';
grant usage on whitelife.* to whitelife@'127.0.0.1' identified by 'whitelife';
grant usage on whitelife.* to whitelife@'%' identified by 'whitelife';


 Step 3. 권한 부여

 권한을 부여 한다. 최소한 권한만 정의 하였다. 사용자 생성시 3가지 종류로 작성 하였다면 권한도 3가지 다 부여해야 한다.

grant select, insert, update, delete, create, drop, index, alter on whitelife.* to whitelife@localhost;
grant select, insert, update, delete, create, drop, index, alter on whitelife.* to whitelife@'127.0.0.1';
grant select, insert, update, delete, create, drop, index, alter on whitelife.* to whitelife@'%';


 Step 4. 적용 하기

 아래 명령어를 실행 한다.

flush privileges;


  Step 5. 확인 하기

 생성한 사용자로 로그인하여 확인해보자. 정상적으로 접속 되는 것을 확인 할 수 있다.

C:\Program Files\MySQL\MySQL Server 5.5\bin>mysql -u whitelife -p whitelife
Enter password: *********
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 29
Server version: 5.5.28 MySQL Community Server (GPL)

Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>


'Database' 카테고리의 다른 글

Mysql Timestamp Column 생성 하기  (0) 2012.12.06
Mysql root 비밀번호 변경하기  (0) 2012.12.03
Oracle 덤프 뜨기  (0) 2012.11.26
count() 에 대해서  (0) 2012.11.16
having 사용하기  (0) 2012.11.15

+ Recent posts