从我的笔记本电脑连接到本地计算机上托管的 SQL(使用 IP)
我在 Windows 7 PC 上设置了 SQL 服务器。
我有一台笔记本电脑,我想从它连接到 SQL 服务器(使用 Visual Studio 2010)。 创建数据库连接时我需要填写“服务器名称”。
我尝试了“My.IP.Address/SQLEXPRESS,custom-port
”,但这不起作用。所有示例都讨论使用格式类似于“TOM-PC/SQLEXPRESS
”的服务器名称,但我有一个重要的要求:
我希望能够从任何地方进行连接(不仅在同一本地网络中),因此我尝试使用 IP 地址(端口不只是 1433,因为我的 ISP 阻止了它)。
自定义端口已打开,并且在测试中可访问。
我一整天都在谷歌搜索这个问题,但找不到解决方案。请帮忙!
谢谢你,
汤姆
I set up an SQL server on my Windows 7 PC.
I have a laptop, from which I want to connect to the SQL server (using visual studio 2010).
I need to fill in a "server name" when creating a database connection.
I tried "My.IP.Address/SQLEXPRESS,custom-port
", but that doesn't work. All examples talk about using server names which are formatted like so "TOM-PC/SQLEXPRESS
", but I have an important requirement:
I want to be able to connect from anywhere (not only when in the same local network), therefore I'm trying to use the IP address (the port isn't simply 1433 since my ISP blocks it).
The custom port is open, and reachable in tests.
I've been Googling this all day long, but can't find a solution. Please help!
Thank you,
Tom
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
要从远程位置访问,您需要在路由器上设置端口转发。如果您有一个面向外部的静态 IP 地址,则可以将其用作服务器地址 (123.123.123.123\SQLEXPRESS),否则您将需要设置动态 DNS 服务,例如 DynDNS.com 将为您的路由器提供主机名。
To access from a remote location, you need to setup port forwarding on your router. If you have a static external facing IP address, then you can use that for your server address (123.123.123.123\SQLEXPRESS), otherwise you will need to setup a dynamic DNS service like DynDNS.com that will give your router a hostname.
不应该是 My.IP.Address:custom-port/SQLEXPRESS 吗?
should it not be My.IP.Address:custom-port/SQLEXPRESS ?
如果您说您在位置 A 有一台具有 SQL 的 PC,并且您希望能够从任何地方访问它,那么您将需要来自 ISP 的静态 IP、具有正确 NAT 规则的防火墙。即便如此,当您在本地(在同一网络内)时,它会是一个与您在当地咖啡店时不同的 IP。
我的建议是使用本地服务器参考并在笔记本电脑上安装 SQL。如果您将工作发布到家里的 PC,那么它也会使用那里的本地 SQL 服务器。这就是我所做的。我使用 RedGate 工具来同步我的数据库。
如果您在同一台计算机(您的笔记本电脑)上有 SQL 和 VS,并且尝试从 VS 连接到 SQL 服务器(例如在调试器中),那么请尝试以下操作:(我一直这样工作)
您可以使用
(local)
或.
作为 SQL 连接中的server
来引用本地计算机。在你的情况下:
或
If you are saying that you have a PC at location A that has SQL and you want to be able to access it from anywhere, well, then you're going to need a static IP from your ISP, a firewall with the proper NAT rules. And even then, it'll be a different IP when you're local (within the same network) than it is when you are at the local coffee shop.
My suggestion would be to use the local server reference and install SQL on your laptop. If you publish your work to your PC at home, then it'll use the local SQL server there too. This is what I do. I use RedGate tools to sync up my DBs.
If you have SQL and VS on the same machine (your laptop) and are trying to connect to the SQL server from VS (e.g. in debugger), then try the following: (I'm working like this all the time)
You can use
(local)
or.
as theserver
in a SQL connection to refer to the local machine.In your case:
or
您是否可能忽略了在配置管理器中从 SQLExpress 打开 TCP/IP?
Is it possible you overlooked turning on TCP/IP fro SQLExpress in the configuration manager?
您尝试过使用通配符吗?比如让别人通过‘%’访问你,既然你想让你的电脑在任何地方都可以被访问,那么你的MySQL主机实际上就是你的IP地址。
Have you tried using a wild card? For example let others access you through '%', since you want your computer to be accessed anywhere, your MySQL host is actually your IP address.