Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a VPS with MySQL 5.5, which is listening only on localhost because of obvious security reasons. I have set up VPN connection from my own machine to that VPS and I connect successfully.

What would be the best way to grant same access to all MySQL databases to anyone connected to the VPN as if it was a localhost request?

I might be asking this question in rather silly way, so if you don't get my idea, I will elaborate.

edit: The VPS is Linux (Cent OS 5.6), if that helps. MySQL is listening on 3306. I have currently forwarded all connections that come from my IP to port 3306 on the public address of the machine to But this is not very convenient, as I tend to travel and when I'm not at home, this method fails.

share|improve this question
up vote 3 down vote accepted

you can let mysql itself listen on connections coming on all interfaces [ comment out bind-address in my.cnf ] and control access using the iptables:

#allow connections from the vpn. insert vpn address range below
IPTABLES -A INPUT -s -p tcp --dport 3306 -j ACCEPT
#allow local connections eg your scripts running locally
IPTABLES -A INPUT -s -p tcp --dport 3306 -j ACCEPT
#deny any other attempts of connecting to mysql
IPTABLES -A INPUT -p tcp --dport 3306 -j DROP

you can be more elaborate and add -i to specify particular interface.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.