我制作数据库程序并使用 localhost 作为主机。我想让我的朋友测试我的程序,但我不知道如何从另一台计算机连接。
PS。我使用 Windows 7 和 MySql。
我制作数据库程序并使用 localhost 作为主机。我想让我的朋友测试我的程序,但我不知道如何从另一台计算机连接。
PS。我使用 Windows 7 和 MySql。
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'
Are both the computers on same network? Then just provide your LAN ip address to your friend. However if you are on internet and not behind a NAT firewall then you can provide him your public ip addres. If you are behind a NAT router then you have to setup port forwarding on your router
you mean connect to your program or your DB? you can replace your "localhost" with IP address to make your program accessible from another computer.
Localhost is the standard hostname given to the address of the loopback network interface. for communication between two computers :