从命名实例更改SQL服务器(如preSS)到本地主机?实例、主机、服务器、SQL

2023-09-04 01:19:13 作者:黑发尤物。

有没有办法从命名实例更改MSSQL EX preSS为localhost?

Is there a way to change a mssql express from a named instance to localhost?

在第一次安装我给我的前MSSQL preSS服务器,名称服务器。现在,工作在一个项目中的Web.config specifcs本地主机,或(本地),我要修改所有这些之前,我迁移数据库或运行应用程序。

When first installing the server I gave my mssql express server, a name. Now, working on a project where the web.config specifcs the localhost, or (local), I have to edit all of these before I migrate the db or run the application.

要连接到我的数据库,我一定要指定实例,而不是本地主机像这样: MyComputerName \实例;数据库= DB_NAME;

To connect to my database, I have to specify my instance instead of localhost like so: MyComputerName\Instance;Database=db_name;"

我想简单地使用:本地主机,数据库= DB_NAME; 这个目前不起作用。

I would like to simply use: localhost;Database=db_name; This currently does not work.

我不希望有重新安装MSSQL,但是我已经考虑过这个选项,如果没有其他选择缴费。

I don't want to have to re-install mssql, however I have considered this an option if no other options are avaiable.

我使用Microsoft SQL Server的防爆preSS版高级服务10.50.2550.0版

I am using "Microsoft SQL Server Express Edition with Advanced Services" version 10.50.2550.0

推荐答案

如果您连接到服务器时没有指定一个实例名称,它就会查看端口 1433

If you don't specify an instance name when connecting to a server, it will look at port 1433.

在默认情况下,在 MSSQLSERVER 实例(即默认值)将被分配这个静态端口。

By default, the MSSQLSERVER instance (i.e. the default) will be assigned this static port.

在默认情况下,任何命名实例将被赋予其使用的是SQL Server Browser服务发现的动态端口。

By default, any named instances will be assigned dynamic ports which are discovered using the SQL Server Browser service.

您可能无法重命名一个实例,但你可以改变它的端口号。

You might not be able to rename an instance, but you can change its port number.

有关您的命名实例,您需要将其设置为静态SQL Server默认的端口,即 1433 。显然TCP / IP协议将需要启用该实例

For your named instance, you need to set it to the static default SQL Server port, i.e. 1433. Obviously TCP/IP will need to be enabled for the instance:

一旦你做到了这一点,应该能够连接到本地主机而不提供一个名称,它只是尝试连接到 1433

Once you've done this, should be able to connect to localhost without supplying a name as it will just try and connect to 1433.