简体   繁体   中英

Make mysql client use ALL_PROXY socks5 server

I want to connect to an aurora serverless database from my local machine. Because the database is only accessible from within the aws cloud, I have setup an ec2 instance running microsocks :

./microsocks -p 8888

I now want to connect using mysql from my machine:

export ALL_PROXY=socks5h://xx.xx.xx.xx:8888

mysql --user=admin --password=XXXX -h database-XXXX.cluster-XXXX.eu-XXXX.rds.amazonaws.com

ERROR 2003 (HY000): Can't connect to MySQL server on 'database...com' (111)

If I run this command on the ec2 instance it succeeds. So I assume that mysql does not respect my proxy settings. If I run curl on my machine it respects the proxy settings.

Note that this is just for testing purposes and I know that this would not be a solution for production use.

You may use proxychains.

yum install  proxychains-ng

edit config file /etc/proxychains.conf , and add this:

[ProxyList]
# add proxy here ...
# meanwile
# defaults set to "tor"
socks5  {your proxy.address} {your.proxy.port} 

Lastly, you can run mysql like this:

proxychains mysql --user=admin --password=XXXX -h database-XXXX.cluster-XXXX.eu-XXXX.rds.amazonaws.com

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM