I make database program and use localhost as host. I want my friend to test my program but I don't know how to connect from another computer.
PS. I use windows 7 and MySql.
We first need to know the IP address on the computer that hosts the website (the one we've been working on since the very beginning). In the terminal, on MAC and LINUX type ifconfig |grep inet , on WINDOWS type ipconfig . Let's assume the IP address of this computer is 192.168.
Open any browser you like and type http://localhost:9999 and it will work like a charm.
You are accesing localhost , meaning you have a web server running on your machine. To access it from Internet, you need to assign a public IP address to your machine. Then you can access http://<public_ip>:<port>/ . Port number is normally 80.
localhost
is just an alias for the loopback address 127.0.0.1, which means this computer.
If you want to communicate with that computer from somewhere else, you'll need to use its real IP address.
For example, see the following "diagram" showing where connectons will go depending on the IP address used:
+-----------+ 10.1.1.8 +-----------+
| MyPC | <------- | YourPC |
| | | |
| 10.1.1.8 | -------> | 10.1.1.9 |
+-----------+ 10.1.1.9 +-----------+
| ^ | ^
| | | |
127.0.0.1-+ 127.0.0.1-+
With Windows, you should be able to get your IP address with ipconfig
(ifconfig
under most UNIX-type systems) and just plug that into your connection parameters where you currently have localhost
.
Keep in mind that you may still need to grant power to the remote IP address to connect, such as with (assuming you're trying to connect from 10.1.1.8
):
GRANT ALL PRIVILEGES ON *.* TO 'mysql'@'10.1.1.8' IDENTIFIED BY 'super-sekrit'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With