Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am connecting to a VPN successfully and now I want to use MySQl Administrator to connect to the MySQL database on the server. I don't know what to put in the Server Host address.

There is a PHP script on the server which connects using localhost. How would I find out what localhost really is over the VPN?

I'm probably asking this question in a really stupid way - sorry about this. This is right on the edge of my knowledge.

share|improve this question
    
Do you know the IP address or DNS name of the MySQL Server? –  Wesley Jul 6 '09 at 18:52
    
I know the name of the website the server is sitting on but once I connect over the VPN it seems I can no longer ping that server –  Alex Andronov Jul 6 '09 at 19:11
    
Pinging a server and being able to contact the server are two different things. Just because it won't respond to ping does not indicate that it is not online... Although if it was responding to ping in the past and it's now not then it's a pretty good bet... –  Mark Henderson Jul 6 '09 at 21:36
add comment

2 Answers 2

up vote 1 down vote accepted

Alex, localhost is the name who resolves to the local loopback adapter present on any machine with a connection and it's adress is 127.0.0.1 - so if a client connects to a service on "localhost" this means it connects to a port on the local machine.

The server also has a public address, which is assigned to the "real" network adapter, lets say 123.123.123.123 - you and the world can reach your server via this adress, but only the ports that are opened to this adapter. For security reasons the mysql port 3306 is only opened to the local loopback adapter 127.0.0.1 by default.

A VPN tunnel will create a virtual but secured connection between your local machine and the server. Your server and also your local machinne will have additional virtual network adapters in this case. Lets say your server has 10.10.10.1 and your local machine 10.10.10.2 at the ends of the tunnel.

If you ping 10.10.10.1 from your local machine the server should answer. (In this case 10.10.10.1 is the address of the host, which could answer your question). But the mysql port is probably still not listening on this interface, because it only listens to 127.0.0.1 - you can change this in the mysql server settings, but make sure it won't listen on the public IP.

The 10.10.10.x is only an example, but how do you find out the real address?

On both your local machine and your server open a terminal window. On the server type "ifconfig" and on the windows machine type "ipconfig" (the spelling idffers in the 2nd character) and the machines tell you the adresses of all their adapters. You can now see which one is the additional vpn adapter on both machines (they have similar addresses).

If you don't want to change the setting of the serer you can "forward" the port, which is a different technique and can be done with ssh or putty. You will have to make a ssh or putty connection from your local machine to the server and forward port 3306 on IP 127.0.0.1 from your server to your local machine.

If you are using putty go to the ssh tunneling section and add a local port forwarding 127.0.0.1:3306 - and if you are using ssh this is the command:

ssh -l remoteusername -L 3306:127.0.0.1:3306 your.servername.com

After the ssh or putty connection is active you have to tell your mysql administration software to connect to localhost (so you put 127.0.0.1 or the word localhost as Server Host), because the port is forwarded and now present on your local machine on 127.0.0.1 - this is the result of the port forwarding technik that the ssh protocol can do. Be sure not to run a mysql service on your local box at the same time.

You mentioned that you loose the connection to your server when you create the tunnel. This is probably a security restriction of the tunneling software. But you should still be able to connect through the tunnel with the mysql admin tool.

share|improve this answer
add comment

How do you know that there is a PHP script using localhost if you don't know the server IP ? If you have ftp/ssh/web access to the server, use the same IP to connect to mysql as the one you use for ftp/ssh/http.
But may be mysql is only listen locally, in this case you will need to connect to the server using ssh and run mysqladmin locally (or you may use things like phpmyadmin)

share|improve this answer
add comment

Your Answer

 
discard

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.