I have setup an Azure app service with a hybrid connection to my local on premise SQL Server 2014.
The connection is just fine I can ping it from app service using tcpping.
However I cannot make the connection to the database. The sqlcmd command fails complaining about the user / pass - but they are correct.
I am using this command
sqlcmd -S <servername> -d Sample_Dev -U xxx -P xxxx -I
I am getting this error:
Sqlcmd: Error: Microsoft SQL Server Native Client 11.0 : Login failed for user 'xxx'
I have searched online for that error and I am unable to make it work. Can you please help me on that ? I really appreciate your help.
Thanks
I was able to make it work by creating a database user directly on mssql and not using AD.
Related
I am currently trying to connect to mssql from the remote server using sqlcmd utility. The command used:
sqlcmd -S <ip> -U my/Username.admin01 -P <password -C
However, when I run the sql command, I received following error:
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Login failed for user 'myUsername.admin01'..
where it removed the "/" in my command. As I checked the existing DB, the username my/Username.admin01 is created using windows authentication, instead of normal sql server authentication, which I believe windows authentication uses the AD in the domain.
Is there any way to access the mssql using sqlcmd utility for the username created by the windows auth? Thanks.
I am finding some problem trying to connect to a SQL Server instance from an Ubuntu machine using sqlcmd. The SQL server instance run on another server that is an always on MS-SQL Server cluster.
So I installed sqlcmd as explained here: https://learn.microsoft.com/it-it/sql/linux/sql-server-linux-setup-tools?view=sql-server-ver15#ubuntu
The SQL server seems to be reachable because I can successfully connect to the 1433 port of its IP via Telnet.
Then I tried to connect to one of my database on this server, in this way:
./sqlcmd -S MY-IP-ADDRESS -d ESB_WSO2_USER_DB -U datacenter\\wso2DBAdmin
Where:
ESB_WSO2_USER_DB is the DB name
datacenter\wso2DBAdmin is the domain\username
It ask me the password, I insert the password (pretty sure that the credential should be ok) but I am obtaining this error message:
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Login failed
for user 'datacenter\wso2DBAdmin'..
Assuming that username and password are correct: what could be the problem? Is it something that could be related to my sqlcmd installation (maybe some missconfiguration), or the driver? or something related to my connection string? or something related to the SQL Server database?
I have SQL Server that uses Kerberos authentication on my company's network. I am trying to setup a Linux system to be able to access that SQL Server using pyodbc. I am new to Kerberos, but have been able to get my Linux (Ubuntu 16.04) box working with Kerberos... Atleast thats what I think. I can do kinit <username> and it recognizes my username and password.
What do I do next?
If I do this:
sqlcmd -S MyDatabase.corp.com
I get this:
sqlcmd: Error: Microsoft ODBC Driver 11 for SQL Server : Cannot generate SSPI context.
Sqlcmd: Error: Microsoft ODBC Driver 11 for SQL Server : SSPI Provider: Cannot find KDC for realm "COMPANYNET.CORP.COM".
I am pretty sure I am just not doing the next step but I haven't found a good source to tell me what to do next. Any help is much appreciated... Thanks!
After much headache and annoying a lot of people at my company I got this to finally work.
Had to get a Service Account setup on the Domain
Had to get a krb5.keytab file made by an AD Admin
Had to setup Kerberos with the correct Domain in my /etc/krb5.conf file
Had to have SPNs set for the target SQL Server (This seems to be the actual cause of the above error message)
Ensure proper permissions set Service Account on SQL Server.
Once above was set I can do:
kinit -k <SERVICE ACCOUNT NAME>
sqlcmd -E -S MyDatabase.corp.com
I am trying to connect to sql server with forced encryption using sqlcmd.
I have added a certificate to sql server and enabled forced encryption.
But the sqlcmd tool is not able to connect to the sql server. Below is the command I am using:
sqlcmd -S"mymachine.mydomain.dom" -b -d"mydatabase" -i"E:\mysqlfile.sql"
-v mode="Load" -N -U"sa" -P"password"
this works when I remove mydomain.dom and -N option like:
sqlcmd -S"mymachine" -b -d"mydatabase" -i"E:\mysqlfile.sql"
-v mode="Load" -U"sa" -P"password"
What may be the reason?
Edit : I have stored the server certificate in both personal and trusted people store. I also ran the follwing query to check the encryption .
SELECT encrypt_option FROM sys.dm_exec_connections
encrypt_option is true for all the sessins.
Edit 2 : I am using a default instance. The certificate CN is mymachine.mydomain.dom. Also another connection to the same database with encrypt=true and using .net code is working fine. So this doesn't seems to be a certificate issue.
Edit 3 : Tcp/ip is enabled in network configuration. Remote connection is also enabled. I also tried executing sqlcmd as administrator but got the same error.
I have my SQLServer 2005 Standard instance configured for mixed mode fine. When using SSMS, none of the sql server logins seem to work. Just "Login failed for user '..'" message. But when I use SQLCMD, it works fine. The behavior is not just for one specific login account. All sql server logins including 'sa' fail when tried via SSMS. Windows logins work fine.
Any ideas?
EDIT1:
When connecting via SQLCMD, I do not specify the -S option. Just the -U and -P
Whereas in SSMS, Server name defaults to the machine name.
In SSMS the server seems to be registered as say xxxxN. When I connect using windows authentication, my ##servername returns xxxx_N.
When I try to use the xxxx_N in SSMS it fails to connect altogether.
Edit2:
When trying via SQLCMD if I give the -S option as xxxxN, it works fine too.
Edit3:
My SQLCMD:
C:...>SQLCMD -U sa -P Password (works)
C:...>SQLCMD -S xxxxN -U sa -P Password (works)
C:...>SQLCMD -U test -P Password (works)
C:...>SQLCMD -S xxxxN -U test -P Password (works)
in SSMS:
ServerType: Database Engine
ServerName: xxxxN
AUthentication: Windows Authentication (works)
ServerType: Database Engine
ServerName: xxxxN
AUthentication: Sql Server Authentication
Login: sa
Password: Password (fail)
ServerType: Database Engine
ServerName: xxxxN
AUthentication: Sql Server Authentication
Login: test
Password: Password (fail)
EDIT 4(Answer)
ODBC connections using sql accounts seem to work fine.
SSMS connections from remote machines work fine also.
This HAS TO BE an issue with local SSMS install. I believe a reinstall would fix this..
Your server/instance name is not consistent between the two.
MyMachineName\Express
is the "most common" instance name.
But yours may vary.
Since sqlcmd "works".
Run sqlcmd, and pass it this command
select [MyServerAndMaybeInstanceName] = ##servername
Then you will know what to put into SSMS ! (ta da!)
EDIT:
You say in sqlcmd, you give it
-U and -P
thus you're using Sql Authentication. (and not windows authentication)
Are you providing Sql Authentication credentials when trying through SSMS ?
I see you said "All sql server logins including 'sa' "
thus you are trying Sql Authentication credentials.
Can you just verify you've tried some Sql Authentication creditials, maybe something besides sa.
EDIT:
Here is a guess, but I hit it one time, a long time ago.
In the SSMS connection box, click "Connection Properties"
Find "Network".
And pick TCP/IP as the network protocol.
especially if the machine is a remote machine.
EDIT:
Here is another poor man's test.
Go to Control Panel /Admin Tools / Data Source (ODBC) / System DSN. And try to add a connection there.
You can also play with the protocols there (named-pipes vs tcp/ip, etc) with the "Client Configuration" button in the Wizard.