I am trying to connect to mssql server (2008 R2) from my ubuntu. I have installed freetds driver.
Below is my configuration in freetds.conf:
[titan]
host = SQL_IP_ADDRESS
tds version = 7.0
instance = CENTERFORALLIED\MSSQLSERVER_2K8
Where CENTERFORALLIED\MSSQLSERVER_2K8 is the instance name.
When I try to connect using below command:
tsql -S titan\MSSQLSERVER_2K8 -U user -P pass
OR
tsql -S titan -U user -P pass
OR
tsql -S SQL_IP_ADDRESS -U user -P pass
its not working. I am getting below error:
locale is "en_IN"
locale charset is "UTF-8"
using default charset "UTF-8"
Msg 18456 (severity 14, state 1) from CENTERFORALLIED\SQLEXPRESS Line 1:
"Login failed for user 'ibuser'."
Error 20002 (severity 9):
Adaptive Server connection failed
There was a problem connecting to the server
I am not sure why this is trying to connect to SQLEXPRESS instance. My instance is MSSQLSERVER_2K8 and I am explicitly mentioned it in config file and even tried in arguments.
instance is MSSQLSERVER_2K8 (w/o the hostname part). You can alternatively conf directly the port.
Note that resolving the instance to a port relies on the SQL Server Browser Service being enabled and started. If is not started then you must use the port explicitly, and the port must be statically configured (not dynamic).
Related
I tried to connect to MSSQl database using freetds, unixODBC in raspberry pi 4.Below are my settings.
[fred]
host = 109.*.*.* # Remote Sql Server's IP addr
port = 1433 # this is default
tds version = 7.4 # this is by the time i post this
client charset =UTF-8
[test]
Driver = FreeTDS
Description = MSSQL Server
Trace = No
Server = fred # IP or host name of the Sql Server
Port = 1433 # This is default
TDS_Version = 7.4
[FreeTDS]
Description=FreeTDS Driver
Driver=/usr/lib/arm-linux-gnueabihf/odbc/libtdsodbc.so
Setup=/usr/lib/arm-linux-gnueabihf/odbc/libtdsS.so
UsageCount=1
I have tested with tsql -H ip -U username -P password but the error still persists. I have also installed pyodbc. I am trying to connect from Pi to MS SQl Server Management studio. Could anyone suggest me to have a successful connection to database? I appreciate all the approaches.
I was able to shrug off this error by using the following call:
bsqldb -S $servername:1433 -D $databasename -U $username -P $password -i $inputfile
As far as documentation states, a qualified server name with the port number allows to bypass the related .conf settings.
I'm trying to connect my local/host machine SQL Server from Laravel vagrant homestead. I've been googling all day trying to connect the host machine's database installing different PHP packages but so far have no lucks. I thought I would remove PHP at this point and try to establish the connection inside homestead using sqlcmd instead.
So, I have installed sqlcmd in homestead and tried to execute the following command to connect to the host machine's database.
sqlcmd -S 10.0.2.2,1433 -U sa -P 'password' -Q "sp_databases"
However, I received the following error:
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Client unable to establish connection because an error was encountered during handshakes before login. Common causes include client attempting to connect to an unsupported version of SQL Server, server too busy to accept new connections or a resource limitation (memory or maximum allowed connections) on the server..
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : TCP Provider: Error code 0x2746.
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Client unable to establish connection.
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Client unable to establish connection due to prelogin failure.
However, If I use sqlcmd on my host machine and execute the following command, I am able to access the database.
sqlcmd -S LAPTOP-ACQES\MSSQL2017 -U sa -P Asdf1234 -Q "sp_databases"
In my Homestead.yaml, I have set up port forwarding from:
ports:
- send: 1433
to: 1433
You say this doesn't work:
sqlcmd -S 10.0.2.2,1433 -U sa -P 'password' -Q "sp_databases"
Yet this does:
sqlcmd -S LAPTOP-ACQES\MSSQL2017 -U sa -P Asdf1234 -Q "sp_databases"
In the former, you are using the IP, but no instance name.
Try:
sqlcmd -S 10.0.2.2\MSSQL2017 -U sa -P 'password' -Q "sp_databases"
Also:
Ensure TCP/IP is enabled in SQL Network Configuration.
Verify SQL Server Browser is running.
Allow remote connections in SQL Server properties.
Lock SQL Network configuration to port 1433 on all adapters, and disable dynamic ports (then restart services).
I am getting the following error when trying to access my azure sql server from terminal using the command
tsql -H 'myserver.database.windows.net' -U 'myuser' -P 'mypass'
Error:
locale is "en_US.UTF-8"
locale charset is "UTF-8"
using default charset "UTF-8"
Error 20017 (severity 9):
Unexpected EOF from the server
OS error 115, "Operation now in progress"
Error 20002 (severity 9):
Adaptive Server connection failed
There was a problem connecting to the server
also tried using settings in freetds.conf but same error
You need to make sure you're using TDS version 7.4. Make sure tsql is up to date (you will very likely have to download, build and install from sources) and then force the version from env:
TDSVER=7.4 tsql -H 'myserver.database.windows.net' -U 'myuser' -P 'mypass'
You can use sqlcmd as well.
sqlcmd -S 'myserver.database.windows.net' -U 'myuser' -P 'mypass'
for configuring sqlcmd use url:
https://learn.microsoft.com/en-us/sql/linux/quickstart-install-connect-ubuntu?view=sql-server-2017
I have installed freetds and it looks working fine, when I try to connect by host:
tsql -H myhost -U myuser -P mypass -p 1433
locale is "C/UTF-8/C/C/C/C"
locale charset is "UTF-8"
using default charset "UTF-8"
1>
I have configured freetds.conf:
[azure]
host = myhost
port = 1433
tds version = 7.0
But when I'm trying to connect by server name (azure) it fails:
tsql -S azure -U myuser -P mypass
locale is "C/UTF-8/C/C/C/C"
locale charset is "UTF-8"
using default charset "UTF-8"
Msg 40532 (severity 20, state 1) from azure:
"Cannot open server "azure" requested by the login. The login failed."
Error 20002 (severity 9):
Adaptive Server connection failed
Tried on macos and debian.
The answer was simple, but strange. When you connect by config file (-S) you should use username#host as login, not just username. It's strange, but when you connect by host (-H), you could use only username (but could use username#host too).
Glad it worked out for you. Check out this doc - http://www.freetds.org/userguide/odbcconnattr.htm
As general practice, we recommend that you use -S
Let me know if you have further questions.
I am trying to connect to a remote SQL Server 2008 from a bash file in a Ubuntu 14.04. I am using FreeTDS and the tsql command to do so.
When I am in the same network as the SQL Server, I can access it using its local ip 192.168.0.2, using the following command:
tsql -S 192.168.0.2 -U <user> -P <password>
The problem is when I try to connect using an IPv6. tsql doesn't seem to recognize the IPv6 I got. Here is what I get when trying to connect (the ip is anonymized):
tsql -S fe80::c74a:ada5:be2e:255f%11
Here is the result:
Error 20012 (severity 2):
Server name not found in configuration files.
locale is "en_US.UTF-8"
locale charset is "UTF-8"
using default charset "UTF-8"
Error 20013 (severity 2):
Unknown host machine name.
There was a problem connecting to the server
What am I doing wrong here? Any help is appreciated
The problem was that I was using freetds v0.91 (which was the latest version on apt-get), which does not have support for IPv6. I upgraded to the latest version, which can be found here. Any version above v0.95 should be fine.