无法连接到SQL Server Express 2012/2016上的本地主机 [英] Can't connect to localhost on SQL Server Express 2012 / 2016

查看:274
本文介绍了无法连接到SQL Server Express 2012/2016上的本地主机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚下载了SQL Express 2012的最新版本,但无法连接到本地主机.我尝试了localhost \ SQLExpress和Windows身份验证,但它给了我一条错误消息,提示无法连接.我在这里想念什么吗?我以前使用过SQL Server 2008,并且从未遇到连接到本地主机的问题.似乎找不到它.同样在服务中,我仅看到一个SQL Server VSS编写器.这是应该的吗?还是我错过了什么?谢谢

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

推荐答案

  • 您需要验证SQL Server服务正在运行.您可以通过转到Start > Control Panel > Administrative Tools > Services并检查服务SQL Server(SQLEXPRESS)是否正在运行来执行此操作.如果没有,请启动它.

    1. You need to verify that the SQL Server service is running. You can do this by going to Start > Control Panel > Administrative Tools > Services, and checking that the service SQL Server (SQLEXPRESS) is running. If not, start it.

    在服务小程序中时,还请确保服务启动它 .

    While you're in the services applet, also make sure that the service SQL Browser is started. If not, start it.

    您需要确保允许SQL Server使用TCP/IP或命名管道.您可以通过在Start > Programs > Microsoft SQL Server 2012 > Configuration Tools(或SQL Server Configuration Manager)和 SQL Server配置管理器,管理单元的路径(根据您的版本).

    You need to make sure that SQL Server is allowed to use TCP/IP or named pipes. You can turn these on by opening the SQL Server Configuration Manager in Start > Programs > Microsoft SQL Server 2012 > Configuration Tools (or SQL Server Configuration Manager), and make sure that TCP/IP and Named Pipes are enabled. If you don't find the SQL Server Configuration Manager in the Start Menu you can launch the MMC snap-in manually. Check SQL Server Configuration Manager for the path to the snap-in according to your version.

    验证您的SQL Server连接身份验证模式是否与您的连接字符串匹配:

    Verify your SQL Server connection authentication mode matches your connection string:

    • 如果使用用户名和密码进行连接,则需要将SQL Server配置为接受"SQL Server身份验证模式":

    • If you're connecting using a username and password, you need to configure SQL Server to accept "SQL Server Authentication Mode":

    -- YOU MUST RESTART YOUR SQL SERVER AFTER RUNNING THIS!
    USE [master]
    GO
    DECLARE @SqlServerAndWindowsAuthenticationMode INT = 2;
    EXEC xp_instance_regwrite
      N'HKEY_LOCAL_MACHINE',
      N'Software\Microsoft\MSSQLServer\MSSQLServer',
      N'LoginMode',
      REG_DWORD,
      @SqlServerAndWindowsAuthenticationMode;
    GO
    

  • 如果使用"Integrated Security = true"(Windows模式)进行连接,并且仅在Web应用程序中进行调试时才会出现此错误,则您需要

  • If you're connecting using "Integrated Security=true" (Windows Mode), and this error only comes up when debugging in web applications, then you need to add the ApplicationPoolIdentity as a SQL Server login:
  • 否则,运行Start -> Run -> Services.msc,如果正在运行,

    otherwise, run Start -> Run -> Services.msc If so, is it running?

    如果它没有运行

    听起来好像您没有安装所有东西.启动安装文件,然后选择选项新安装或向现有安装添加功能".从那里应该可以确保已安装数据库引擎服务.

    It sounds like you didn't get everything installed. Launch the install file and chose the option "New installation or add features to an existing installation". From there you should be able to make sure the database engine service gets installed.

    这篇关于无法连接到SQL Server Express 2012/2016上的本地主机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆