2011-11-22 4 views
0

내 프로그램은 원격 MySQL 서버와 작동하며, 일을 더 빨리하기 위해 내 컴퓨터에 로컬 프록시 서버를 만들고 싶습니다 (연결 풀, 캐시 쿼리 등). 하나의 콘솔에서 http://dev.mysql.com/doc/refman/5.1/en/mysql-proxy.html원격 MySQL 서버용 mysql-proxy

내가 달릴 :

[email protected]:~$ mysql-proxy --proxy-backend-addresses=$MYSQL --log-level=debug2011-11-22 09:43:30: (message) mysql-proxy 0.8.2 started 
2011-11-22 09:43:30: (debug) max open file-descriptors = 1024 
2011-11-22 09:43:30: (message) proxy listening on port :4040 
2011-11-22 09:43:30: (message) added read/write backend: qa-srv:3308 

그리고 다른 콘솔에 : 나는 문서 갔다 대신 원격 서버의 데이터베이스를 보는, 그러나

[email protected]:~$ mysql --user root --host=localhost --port=4040 
Welcome to the MySQL monitor. Commands end with ; or \g. 
Your MySQL connection id is 81 
Server version: 5.1.41-3ubuntu12.10 (Ubuntu) 

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

mysql> show databases; 

(품질 보증 -srv) 로컬 서버의 데이터베이스를 보았습니다!

나는 또한이 시도 :

[email protected]:~$ sudo service mysql stop 
mysql stop/waiting 
[email protected]:~$ mysql-proxy --proxy-backend-addresses=$MYSQL --log-level=debug --proxy-address=0.0.0.0:3306 
2011-11-22 14:14:25: (message) mysql-proxy 0.8.2 started 
2011-11-22 14:14:25: (debug) max open file-descriptors = 1024 
2011-11-22 14:14:25: (message) proxy listening on port 0.0.0.0:3306 
2011-11-22 14:14:25: (message) added read/write backend: qa-srv:3308 

그리고 다른 콘솔에

:

[email protected]:~$ mysql --user root 
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) 

어떻게 내가 할 수있는 내가 대신 MySQL의 데몬의 프록시를 실행하려고

[email protected]:~$ mysql --user root --host=qa-srv --port=4040 
ERROR 2003 (HY000): Can't connect to MySQL server on 'qa-srv' (111) 

내 mysql 클라이언트에게 로컬 프록시를 통해 원격 서버에 연결하도록 지시 하시겠습니까?

답변

2

만세! 해결책을 찾았습니다. 콘솔 A의

: 콘솔 B에

[email protected]:~$ mysql-proxy --proxy-backend-addresses=qa-srv:3308 --log-level=debug --proxy-address=127.0.0.1:3306 
2011-11-22 18:55:02: (message) mysql-proxy 0.8.2 started 
2011-11-22 18:55:02: (debug) max open file-descriptors = 1024 
2011-11-22 18:55:02: (message) proxy listening on port 127.0.0.1:3306 
2011-11-22 18:55:02: (message) added read/write backend: qa-srv:3308 

: 또는

[email protected]:~$ mysql -u <username-on-remote-database> -h 127.0.0.1 

또는, 당신은 여전히 ​​활성 로컬 데이터베이스를 원하는 경우 :

: 콘솔 A의

[email protected]:~$ mysql-proxy --proxy-backend-addresses=qa-srv:3308 --log-level=debug 
2011-11-22 18:55:02: (message) mysql-proxy 0.8.2 started 
2011-11-22 18:55:02: (debug) max open file-descriptors = 1024 
2011-11-22 18:55:02: (message) proxy listening on port 127.0.0.1:3306 
2011-11-22 18:55:02: (message) added read/write backend: qa-srv:3308 

콘솔 B :

[email protected]:~$ mysql -u <username-on-remote-database> -h 127.0.0.1 -P 4040 
+0

0.8.5에서 작동하지 않았습니다. –