Search code examples
sql-serverdatabasewindows-8

Not able to login to sql server


I am not able to login to sql server 2012

error

Sqlcmd: Error: Microsoft SQL Server Native Client 11.0 : Named Pipes Provider: C ould not open a connection to SQL Server [67]. . Sqlcmd: Error: Microsoft SQL Server Native Client 11.0 : Login timeout expired. Sqlcmd: Error: Microsoft SQL Server Native Client 11.0 : A network-related or in stance-specific error has occurred while establishing a connection to SQL Server . Server is not found or not accessible. Check if instance name is correct and i f SQL Server is configured to allow remote connections. For more information see SQL Server Books Online..

Command I am using to login "sqlcmd -S MSSQLSERVER -E"

I also tried enabling TCP/IP under sql server configuration manager.

Thanks


Solution

  • If you are are running the SQLCMD from the machine where the SQL Server is installed, you need to use the below command.

    SQLCMD -E

    If the SQL Server is on another machine, you need to use the below command. The <ServerName> is the machine name, but not the instance name.

    SQLCMD -E -S <ServerName>

    You need to check if SQL Server is running or not. Press Win + R and enter services.msc and press enter. (You need to do it on the machine where SQL Server is installed)

    This will open the Services window. Scroll through and find SQL Server (MSSQLSERVER) and select it.

    On the left side of it, you should be able to see the status. Check if the process is already running or now. If not, you need to start it before using the SQL Server.

    If the SQL Server is up and running, you need to check if SQL Server is accessible from your machine. You can check it by executing below command from cmd prompt.

    TELNET <ServerName> 1433

    If this command does not give you any error, and opens a blank window, that means you are able to reach SQL Server machine. This will rule out any firewall issues. All you need to check is if the SQL Server instance is running or not.