Can't connect to localhost on SQL Server Expre

2019-01-04 08:03发布

I just downloaded the latest version of SQL Express 2012 but I cannot connect to localhost. I tried localhost\SQLExpress and Windows authentication but it gives me an error message saying cannot connect. Am I missing something here? I've used SQL Server 2008 before and I've never had issues connecting to localhost. It seems that it can't even find it. Also in the Services I only see a SQL Server VSS Writer. Is this the way it should be? Or am I missing something? Thanks

13条回答
干净又极端
2楼-- · 2019-01-04 08:53

My situation

  • empty Instance Name in SQL Server Management Studio > select your database engine > Right Mouse Button > Properties (Server Properties) > Link View connection properties > Product > Instance Name is empty

  • Data Source=.\SQLEXPRESS did not work => use localhost in web.config (see below)

Solution: in web.config

xxxxxx = name of my database without .mdf yyyyyy = name of my database in VS2012 database explorer

You can force the use of TCP instead of shared memory, either by prefixing tcp: to the server name in the connection string, or by using localhost.

http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlconnection.connectionstring%28v=vs.110%29.aspx

查看更多
Ridiculous、
3楼-- · 2019-01-04 08:54

First check SQL Server Service is Running or stopped, if it is stopped just start it, to do so..just follow the below steps.

1.Start -> Run ->Services.msc

enter image description here

  1. Go to Standard tab in services panel then search for SQl Server(SQL2014)

"SQL2014" is given By me, it may be Another Name in your case

enter image description here

that's it once you start the SQL Service, you are able to connect local database.

hope it will help someone.

查看更多
淡お忘
4楼-- · 2019-01-04 08:57

in SQL SERVER EXPRESS 2012 you should use "(localdb)\MSSQLLocalDB" as Data Source name for example you can use connection string like this

Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=master;Integrated Security=True;
查看更多
爷、活的狠高调
5楼-- · 2019-01-04 08:57

Try changing the User that owns the service to Local System or use your admin account.

Under services, I changed the Service SQL Server (MSSQLSERVER) Log On from NT Service\Sql... To Local System. Right click the service and go to the Log On Tab and select the radio button Local System Account. You could also force another User to run it too if that fits better.

查看更多
Luminary・发光体
6楼-- · 2019-01-04 08:59

This is odd I have a similar problem. I downloaded the package for SQL 2012 Express with Tools but the Database Engine was not install.

I donloaded the other one from the MS site and this one installed the database engine. After a reboot the services were listed and ready to go.

查看更多
Viruses.
7楼-- · 2019-01-04 09:01

Goto Start -> Programs -> Microsoft SQL ServerYYYY -> Configuration Tools -> SQL Server YYYY Configuration Manager or run "SQLServerManager12.msc".

Make sure that TCP/IP is enabled under Client Protocols.

Then go into "SQL Server Network Configuration" and double click TCP/IP. Click the "IP Addresses" tab and scroll to the bottom. Under "IP All" remove TCP Dynamic Ports if it is present and set TCP Port to 1433. Click OK and then go back to "SQL Server Services" and restart SQL Server instance. Now you can connect via localhost, at least I could.

enter image description here

查看更多
登录 后发表回答