Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
396 views
in Technique[技术] by (71.8m points)

.net - Change a Sql-Server (express) from a named instance to localhost?

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

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.

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

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

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

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

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

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.

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:

enter image description here

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...