Is there a difference between (local), '.' and localhost?

后端 未结 3 1204
情歌与酒
情歌与酒 2021-01-03 20:10

I\'ve used all three of these when making local programmatic connections to databases. Is there any real difference between them?

相关标签:
3条回答
  • 2021-01-03 20:41

    As far as I know the dot "." and "local" are windows application terms, not a "standard" term, localhost resolves to 127.0.0.1 in the TCP/IP level so if you want to make sure you are "compatible" across platforms you should use either localhost or 127.0.0.1

    0 讨论(0)
  • 2021-01-03 20:48

    The final result is the same. The difference is:

    • 'localhost' resolves at the TCP/IP level and is equivalent to the IP address 127.0.0.1
    • Depending on the application "(local)" could be just an alias for 'localhost'. In SQLServer, '(local)' and '.' mean that the connection will be made using the named pipes (shared memory) protocol within the same machine (doesn't need to go through the TCP/IP stack).

    That's the theory. In practice, I don't think there is substantial difference in performance or features if you use either one of them.

    0 讨论(0)
  • 2021-01-03 21:03

    They are generally synonyms. However, it depends on the application you are configuring. As long as the app understands what you mean, it shouldn't result in a performance loss. At least, not one you have to root out prematurely, if you get my drift.

    0 讨论(0)
提交回复
热议问题