简体   繁体   中英

connect to SQL hosted on a local machine from my laptop (using an IP)

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

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.

它不应该是My.IP.Address:custom-port / 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 (eg 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

Is it possible you overlooked turning on TCP/IP fro SQLExpress in the configuration manager? 替代文字

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM