We've had this problem for a while now. When we work in the IUAV, we have excellent internet connection but the MySql connections are blocked off. This makes it hard for us to do testing beyond using HSQLDB + DBUnit + JUnit. The first part of the solution is to tunnel the connection through SSH. In order to do this...
- Ping the server (your.server.net), get the actual IP and copy it somewhere (this will be explained later)
- Start putty
- Put the actual IP into the hostname field
- Under the tree menu, goto Connection-->SSH-->Tunnels
- For Source Port, put the "MySQL port" (default: 3306)
- For Destination, put "localhost:MySQL port" (default: 3306)
- Now connect to the server and login
- Your computer's port MySQL port should now be the server's tunneled MySQL port. You can now connect to it using MySQL admin tools
This was all well and good that we could connect to localhost:3306 to access the MySQL database remotely, however, we this still meant we had to change all of our project configurations to adapt to the change of the hostname from your.server.net to localhost. This was feasible, but not practical. So instead, this is what we came up with.
- For Windows OS', navigate to C:\windows\system32\drivers\etc and find the hosts file
- Open the hosts file with notepad
- Append "127.0.0.1 your.server.net" to the end of the file
- Change all Non-tunneled connections to the actual IP address of your.server.net so as not to connect to yourself at 127.0.0.1 (e.g. pinging your.server.net would not work with the host file changed)
Since the change is made only in one place, it makes it much easier to do the testing and it means less errors switching around configurations all the time.
No comments:
Post a Comment