Database ( DB )/Database

mysql 접속제한 해제

노루아부지 2019. 8. 5. 16:51

1. mysql 접속

 

   - mysql -u root -p

 

   - pw 입력

 

 

 

2. DB change

 

   - use mysql;

 

 

 

3. 계정정보 조회

 

   - select host, user, password from user;

 

   - 출력결과

 

     +-----------+------+-------------------------------------------+

     | host      | user | password                                                   |

     +-----------+------+-------------------------------------------+

     | localhost | root | 보안상 삭제                                                 |

     | 127.0.0.1 | root | 보안상 삭제                                                |

 

     +-----------+------+-------------------------------------------+

 

   - 위와 같이 local로만 접근이 가능하도록 설정되어 있었습니다.

 

 

 

4. 권한 부여

 

   - grant all privileges on *.* to 'root'@'%' identified by 'root계정 비밀번호';

 

   - ex) root의 pw가 1234라고 가정 할 시

 

         grant all privileges on *.* to 'root'@'%' identified by '1234';

 

 

 

5. 계정정보 조회

 

   - select host, user, password from user;

 

   - 출력결과

 

      +-----------+------+-------------------------------------------+

      | host      | user | password                                                   |

      +-----------+------+-------------------------------------------+

      | localhost | root | 보안상 삭제                                                 |

      | 127.0.0.1 | root |                                                               |

      | %         | root |                                                                 |

      +-----------+------+-------------------------------------------+

 

 

6. reflash (DB가 windows에 설치되어 있을 경우는 여기까지)

 

   - flush privileges;

 

7. port open

   - iptables -I INPUT 1 -p tcp --dport 21 -j ACCEPT 

   - iptables -I OUTPUT 1 -p tcp --dport 21 -j ACCEPT 

   - service iptables save

   - /etc/init.d/iptables restart

 

8. my.cnf 설정 (linux 사용자는 계속 진행)

 

   - vi /etc/my.cnf

 

     를 입력 후 편집 창이 뜨면 파일 내용 중에

 

     bind-address = 127.0.0.1

 

     이 혹시 있다면 주석 처리 후 저장

 

 

 

9. mysql 재시작

 

   - /etc/init.d/mysqld restart

728x90

'Database ( DB ) > Database' 카테고리의 다른 글

postgresql에서 idle 강제 kill  (0) 2019.08.05
postgresql initdb failed  (0) 2019.08.05
postgresql 8.1.4(8.3.1) install  (0) 2019.08.05
postgresql 외부 접속  (0) 2019.08.05
postgresql vaccum  (0) 2019.08.05
loading