从我的笔记本电脑连接到本地计算机上托管的 SQL(使用 IP)

发布于 2024-10-05 08:44:34 字数 440 浏览 0 评论 0原文

我在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

莳間冲淡了誓言ζ 2024-10-12 08:44:34

要从远程位置访问,您需要在路由器上设置端口转发。如果您有一个面向外部的静态 IP 地址,则可以将其用作服务器地址 (123.123.123.123\SQLEXPRESS),否则您将需要设置动态 DNS 服务,例如 DynDNS.com 将为您的路由器提供主机名。

DynDNS Free 允许您创建
指向您家的主机名或
办公室 IP 地址,提供
易于记忆的 URL,以便快速访问。
我们还提供了更新机制
这使得主机名可以与
您的动态 IP 地址。我们继续
免费向
互联网社区正如我们所做的那样
近10年了。

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.

DynDNS Free allows you to create a
hostname that points to your home or
office IP address, providing an
easy-to-remember URL for quick access.
We also provide an update mechanism
which makes the hostname work with
your dynamic IP address. We continue
to offer this service free to the
Internet community as we have done so
for nearly 10 years.

冰葑 2024-10-12 08:44:34

不应该是 My.IP.Address:custom-port/SQLEXPRESS 吗?

should it not be My.IP.Address:custom-port/SQLEXPRESS ?

清眉祭 2024-10-12 08:44:34

如果您说您在位置 A 有一台具有 SQL 的 PC,并且您希望能够从任何地方访问它,那么您将需要来自 ISP 的静态 IP、具有正确 NAT 规则的防火墙。即便如此,当您在本地(在同一网络内)时,它会是一个与您在当地咖啡店时不同的 IP。

我的建议是使用本地服务器参考并在笔记本电脑上安装 SQL。如果您将工作发布到家里的 PC,那么它也会使用那里的本地 SQL 服务器。这就是我所做的。我使用 RedGate 工具来同步我的数据库。


如果您在同一台计算机(您的笔记本电脑)上有 SQL 和 VS,并且尝试从 VS 连接到 SQL 服务器(例如在调试器中),那么请尝试以下操作:(我一直这样工作)

您可以使用(local). 作为 SQL 连接中的 server 来引用本地计算机。

在你的情况下:

(local)\SQLEXPRESS

.\SQLEXPRESS

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 the server in a SQL connection to refer to the local machine.

In your case:

(local)\SQLEXPRESS

or

.\SQLEXPRESS
氛圍 2024-10-12 08:44:34

您是否可能忽略了在配置管理器中从 SQLExpress 打开 TCP/IP?
替代文本

Is it possible you overlooked turning on TCP/IP fro SQLExpress in the configuration manager?
alt text

请止步禁区 2024-10-12 08:44:34

您尝试过使用通配符吗?比如让别人通过‘%’访问你,既然你想让你的电脑在任何地方都可以被访问,那么你的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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文