메뉴 닫기

Mysql DB 생성 및 권한. 특정아이피, 대역에 대한 접근 허용.(Word_Press 사용 고객측 제공 매뉴얼 링크용)

외부 접속 로컬 접속 할지 권한 부여

grant all privileges on dbname.* to dbuser@localhost identified by ‘user_password’ with grant option;

1. DB 생성
mysql>CREATE DATABASE db_name;
mysql>CREATE SCHEMA db_name DEFAULT CHARACTER SET utf8; //기본 캐릭터 지정

mysql>DROP DATABASE db_name; //DB삭제

02. USER 생성
mysql> CREATE USER ‘userID’@’localhost’ IDENTIFIED BY ‘user_password’; // localhost 내부만 사용할 때
mysql> CREATE USER ‘userID’@’%’ IDENTIFIED BY ‘user_password’; // % 외부접속 허용

mysql> DROP USER userID@localhost; // localhost 내부만 사용할 때
mysql> DROP USER userID@’%’ ; // % 외부접속 허용

02. DB사용권한 설정
mysql>GRANT SELECT, INSERT, UPDATE ON db_name.* TO userID@ localhost;
*권한의 종류: SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER

mysql> GRANT ALL ON db_name.* TO userID@’localhost’;
mysql> GRANT ALL ON db_name.* TO userID@’%’;
mysql> GRANT ALL ON db_name.* TO userID@’192.168.5.%’; //C 클래스 전체
mysql> GRANT ALL ON db_name.* TO userID@’192.168.5.10′; //특정IP

mysql> REVOKE ALL ON db_name. table_name FROM userID@’localhost’;

mysql> FLUSH PRIVILEGES;

특정 사용자의 grant 목록조회
mysql> show grants for ‘root’;
mysql> show grants for ‘root’@’localhost’;
mysql> show grants for ‘root’@’123.456.78.9’;
테이블 컬럼정보: mysql> show columns form table_name; or DESC table_name;

mysql> SELECT Host FROM mysql.user WHERE user=’root’;

+—————+

| Host |

+—————+

| 127.0.0.1 |

| localhost |

+—————+

2 rows in set (0.00 sec)

root는 내부에서만 접속 가능하다는 설정이 되어 있다.

변경

1. 모든 ip 허용

mysql> INSERT INTO mysql.user (host,user,password) VALUES (‘%’,’root’,password(‘패스워드’));

mysql> GRANT ALL PRIVILEGES ON *.* TO ‘root’@’%’;

mysql> FLUSH PRIVILEGES;

2. 특정 대역 허용

mysql> INSERT INTO mysql.user (host,user,password) VALUES (‘123.234.%’,’root’,password(‘패스워드’));

mysql> GRANT ALL PRIVILEGES ON *.* TO ‘root’@’123.234.%’;

mysql> FLUSH PRIVILEGES;

3. 특정 IP 허용(1개씩)

mysql> INSERT INTO mysql.user (host,user,password) VALUES (‘123.234.345.456′,’root’,password(‘패스워드’));

mysql> GRANT ALL PRIVILEGES ON *.* TO ‘root’@’123.234.345.456’;

mysql> FLUSH PRIVILEGES;

4. 변경 후 복구 방법

mysql> DELETE FROM mysql.user WHERE Host=’%’ AND User=’root’;

mysql> FLUSH PRIVILEGES;

 

 

[polldaddy rating=”7739789″]

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x