MySQL MySQL 원격 접속하기

황제낙엽 2007.03.09 06:38 조회 수 : 270 추천:113

sitelink1 http://www.sqlgate.com/kr/phpBB2/http://....php?t=288 
sitelink2  
extra_vars5  
extra_vars6  

 

Access denied for user '유저명'@'211.xxx.xxx.xxx' (using password: YES)

본 에러는 MySQL 서버에 원격지 클라이언트 프로그램(SQLGate for MySQL) 이 접근 할수 있는 권한이 없기 때문입니다.

MySQL 서버 관리자에게 외부에서 접근 할수 있도록 요청하시기 바랍니다.

만약 Grant 권한을 줄수 있는 권한이 있으시다면 MySQL 을 텔넷이나 기타 프로그램으로 접속하여 해당 유저가 외부에서 접속이 가능하도록 세팅해 줍니다

신규유저에게 외부 접속 권한주기

1. MySQL 서버에 root 유저 또는 루트 권한의 유저로 접속합니다.

[root@server bin]# ./mysql -uroot mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 47452 to server version: 4.1.11-max

Type 'help;' or 'h' for help. Type 'c' to clear the buffer.

root@server]# mysql -uroot -p mysql

mysql> use mysql
Database changed

2. 접속할 데이타베이스를 선택합니다.
mysql> create database SampleDatabase; Query OK, 1 row affected (0.01 sec)

3. 접속할 유저를 생성합니다.
host 값에 유저가 접속할 위치를 지정합니다.
로컬접속 : localhost
원격접속 : % -- 어디서든 접속 가능
원격접속 : 192.168.1.100 -- 특정 아이피만 접속 가능
원격접속 : 192.168.1.*** -- 특정 아이피만 접속 가능

mysql> insert into user (host,user,password) values ('%','antuser',password('antuser'));
Query OK, 1 row affected (0.00 sec)

4. 데이타베이스의 접속 권한을 줍니다.
- MySQL 4.1.x 기준
mysql> insert into db values ('%','SampleDatabase','antuser','y','y','y','y','y','y','y','y','y','y','y','y');
Query OK, 1 row affected (0.00 sec)

- MySQL 3.x 기준
mysql> insert into db values ('%','SampleDatabase','antuser','y','y','y','y','y','y','y','y','y','y');
Query OK, 1 row affected (0.00 sec)

- GRANT 명령으로 주기
  >use mysql        <-작업할
  >GRANT ALL PRIVILEGES on db.* to root@'192.168.1.4/255.255.255.0';  
        
        >위에 문장은. 192.168.1.4 IP와 root계정으로 들어오는 녀석에게 모든 권한을 허용한다는 뜻입니다.
         혹은   GRANT ALL PRIVILEGES on db.* to root@'%'; 이렇게 하면 모든 원격접속을 허용한다는 뜻이구요.
         저는 갠적으로 요피 접속할때 어뎁터가 변경이 되서  IP가 바뀌는 일이 있어서 그냥 모든 접속으로 해놓습니다.  
         즉,  grant all privileges on *.* to 유저@"%" identified by '암호' with grant option; 이런식으로 사용합니다.

  > select host,use from user;      <- Select 문아시죠? 이렇게 하면.  user라는 테이블에 host,user라는 필드를 보여주게 됩니다.
    +-----------+------+
    | host          | user |
    +-----------+------+
    | %             | root  |
    | localhost  |         |
    | localhost  | root   |
    | yopy        |         |
    | yopy        | root   |
    +-----------+------+
    이런식으로 결과가 나오게 됩니다. 올바로 적용이 되었군요.

5. 정보를 커밋합니다.
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

6.SQLGate for MySQL 실행후 접속 정보를 입력합니다.

유저명 : antuser
패스워드 : antuser
서버IP : 접속할 MySQL 서버
포트 : 1521
테이타베이스 : SampleDatabase
캐릭터셋 : None

7.[연결] 버튼을 클릭합니다.