SA default password SQL Server on Linux - sql-server

I installed SQL Server 2017 on Linux on a CentOS 7 derivate. Now I want to login with the command: "sqlcmd -S 172.0.0.1 -U SA". But I never set up a password. How am I able to login to the SQL Server? Root password is also not working. Could it be that the problem is somewhere earlier?
I tried as well to connect with "root", "sa" and the root password, also with Blank password and "Password123", according to old default passwords.
sqlcmd -S 127.0.0.1 -U sa
I get the following error:
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Login timeout expired.
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : TCP Provider: Error code 0x2749.
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : A network-related or instance-specific error hasile establishing a connection to SQL Server. Server is not found or not accessible. Check if instance nam and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online.

Related

Windows MSSQL user login connections error

I created a user call root and the password is test in MSSQL
but the error occur after I run the command
sqlcmd -S laptop-3l55biaa\test\MSSQLSERVER01 -U root -P test
not working either in SSMS
error info
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : SQL Server Network Interfaces: Error Locating Server/Instance Specified [xFFFFFFFF]. .
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Login timeout expired.
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : A network-related or instance-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 if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online.
I'm not sure if the server/instance name is valid. From the docs, the argument for the -S option has the format [protocol:]server[\instance_name][,port], so I'm not sure what the test part is in your URL. From experience (if I remember correctly), the URL should be something like machineName\MSSQLSERVER01, or if on local host just .\MSSQLSERVER01.
Update
Regarding .\instancename - it looks like that is some additional functionality that SSMS has (and probably ADS) for connecting to instances on the same machine as the client. Sqlcmd doesn't seem to support it (my bad), and instead of the . you have to type localhost.
To sum up, in order to connect to a local instance listening on the default 1433 port you can just use -S localhost or (in case the port is not default or you want to use the name) -S localhost\instanceName.

Getting Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server When trying to run a batch script

I am using XAMPP for creating a local SQL Server instance to run a SQL script. the issue here is, when I run the script I get the following error. What is going wrong here?
Code:
sqlcmd -S localhost -d mysqldb -U uname -P pass -i C:\query2.sql
PAUSE
Error:
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Named Pipes Provider: Could not open a connection to SQL Server [2].
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Login timeout expired.
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : A network-related or instance-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 if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online.
sqlcmd is for SQL Server, you i couldn't connect to MySQL with it as #james Z mentioned. They are completely different database products. I tried using mysql commmand
C:\Software\XAMPP\mysql\bin\mysql --host=hostname --port=portnumber -D dbname -u username --password=**** < path to sql file

Microsoft SQL Server on linux container

I installed the following SQL Server on a Linux Container as this site:
https://learn.microsoft.com/en-us/sql/linux/quickstart-install-connect-docker?view=sql-server-ver15&pivots=cs1-bash
But when I am trying to connect from outside I get the following errors:
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : TCP Provider: The wait operation timed out.
.
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Login timeout expired.
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : A network-related or instance-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 if SQL Server is configured to allow remote connections. For
more information see SQL Server Books Online..
From inside the container I am able to connect either as localhost either from the container;s ip.
Any suggestion?

Use SQLCMD to connect to Windows 2003 server

I have a series of SQL Server instances that I need to connect to from inside a docker container using SQLCMD. These target SQL Server instances frustratingly have different versions with some on Windows Server 2012 and some on Windows Server 2003. When I try to connect to the Windows Server 2012 instances and execute sql commands using a command such as sqlcmd -S IP_Address,Port_No -U username -P password -i input_file.sql, it works perfectly. When I try the same for the Windows Server 2003 instances, I get the following error:
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Login timeout expired.
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : TCP Provider: Error code 0x2AF9.
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : A network-related or instance-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 if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online..
Is this just a situation where the connection syntax changes for Windows Server 2003? I have tried many different tweaks to the connection string but each returns the same message? Is SQLCMD even supported for Windows Server 2003? I would really appreciate any suggestions. Thank you.

Can not connect to remote SQL Server using sqlcmd

I have a Microsoft SQL Server, running in a Window Server 2012 R2 Standard. The configuration for this SQL Instance is: Servername: IP\SQLEXPRESS( IP here is the IP address of the Window Server) with SQL authentication username and password.
I would like to connect to this remote database from my local machine, so I installed sqlcmd on my local machine Win 7, and tried the syntax to connect to this remote server: sqlcmd -S IP\SQLEXPRESS -U username -P password, but then I got some error messages:
Sqlcmd: Error: Microsoft ODBC Driver 13 for SQL Server : SQL Server
Network Inte rfaces: Error Locating Server/Instance Specified
[xFFFFFFFF]. .
Sqlcmd: Error: Microsoft ODBC Driver 13 for SQL Server : Login timeout
expired.
Sqlcmd: Error: Microsoft ODBC Driver 13 for SQL Server : 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..
I searched some solutions in the Internet and did some configurations for the SQL Server, such as: enabled remote connection in SQL Server, activate TCP/IP Protocol, open incoming TCP Port 1433 by defining new rule in Windows Firewall of remote server, open outgoing TCP Port 1433 in my local Win 7 machine. But it seems there changes are not work in my case. Can anyone give me some hints here to fix this remote connecting problem?
Thank you in advance!
try use only sqlcmd -S IP
not IP\SQLEXPRESS

Resources