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.
Related
I have install the driver odbc 2.3.0 on linux by this reference: https://www.microsoft.com/en-ca/download/confirmation.aspx?id=28160
All these steps work correctly.
This is my configation:
SERVER:
Oracle server is on linux
SQL Server is on windows
SQL Server:
My login and password are the same. It's: demo
When I use cmd and I use the command: "ipconfig", I can get my IP
My IP is: 192.168.0.106
This is how I do my connection manually and it work:
After the installation, i have configure my files odbinst.ini and odbc.ini
This is my file odbcinst.ini:
This is my file odbc.ini:
This is where my driver is download:
My instance name is MSSQLSERVER and TCP-IP and listen all are enable:
Dynamic port is blank and static port is 1433:
As you see, I can be connect on localhost with the command line:
sqlcmd -S 192.168.0.106 -d demo -U demo -P demo
But, I can't connect with my Oracle server on putty with this command line:
isql MSSQLSERVER -v
Why it don't work?
The server is start
Allows remotely connexion is enable
I have add port 1433 in firewall setting
I tried to disable the firewall, nothing change
Something is wrong in my configuration?
Problem reseolve :
Change sqlServer Localhost to SqlServer.
You can't connect 2 server if they are on localhost. You need an oracle SQL Server and SQlServer working not on LocalHost
I am trying to connect to a remote MSSQL DB from a MacOS.
I am able to connect to the remote DB using freetds
tsql -H servername.database.windows.net -U username -P password -D database_name -p 1433
But as I make an entry in the /usr/local/etc/freetds.conf file with following settings
[dbservername]
host = servername.database.windows.net
port = 1433
database = database_name
tds version = 7.3
And try to connect using
tsql -S dbservername -U username -P password
I get the following error
locale is "C/UTF-8/C/C/C/C"
locale charset is "UTF-8"
using default charset "UTF-8"
2Msg 40532 (severity 20, state 1) from dbservername:
"Cannot open server "dbservername" requested by the login. The login failed."
Error 20002 (severity 9):
Adaptive Server connection failed
There was a problem connecting to the server
tsql -C output
Compile-time settings (established with the "configure" script)
Version: freetds v1.00.48
freetds.conf directory: /usr/local/Cellar/freetds/1.00.48/etc
MS db-lib source compatibility: no
Sybase binary compatibility: no
Thread safety: yes
iconv library: yes
TDS version: 7.3
iODBC: no
unixodbc: no
SSPI "trusted" logins: no
Kerberos: no
OpenSSL: yes
GnuTLS: no
MARS: no
Any idea how to fix that?
The problem is that FreeTDS is looking for your configuration file in a different directory. tsql -C shows that it is expecting the file to be in /usr/local/Cellar/freetds/1.00.48/etc.
Move freetds.conf from /usr/local/etc/ to /usr/local/Cellar/freetds/1.00.48/etc and give it a try again. Good luck!
A little late to answer, but it's required to write the username as:
username#servername
when connected to Azure Database (sqlserver in Azure)
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 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).