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)
Related
I'm in a linux container using the gem file tiny_tds (verions 2.1.1) to try to connect to sql server on an Azure Managed instance.
The code I'm using to connect is this:
client=TinyTds::Client.new(:username=>'username#full.server.name', :password=> 'password', :host=>'full.server.name.database.windows.net', :port=>3342, :database=>'database', :azure=>true)
I've tried running this both from the ruby console, as well as from within the container.
Here is the info for the freetds that I'm using:
Version: freetds v1.00.91
freetds.conf directory: /usr/local/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
I'm consistently getting the error message:
Login failed for user 'username#full.server.name
Curiously, I'm able to connect via freetds:
tsql -H full.server.name.database.windows.net -U username -D database -p 3342 -P password
I'm wondering if it has something to do with the server/host having multiple '.' characters in the host name.
Also, from what I've read about tiny_tds, when connecting to Azure, the username needs to have the #servername appended to it.
I have tried several version of tiny_tds (all to no effect).
I have also tried many various permutations of the connection string. Nada.
Please let me know if you have any suggestions!!
I'm trying to connect with a SQL Server from OS Capitan's console, I installed FreeTDS with brew install homebrew/versions/freetds091 and edited the file /usr/local/Cellar/freetds091/0.91.112/etc
# A typical Microsoft server
[egServer70]
host = myhost.domain.com
port = 1433
tds version = 7.0
Then, when I try to connect with tsql -S myhost.domain.com -U user -P password and I get the following error:
locale is "C/UTF-8/C/C/C/C"
locale charset is "UTF-8"
using default charset "UTF-8"
75Error 20009 (severity 9): Unable to connect: Adaptive Server is unavailable or does not exist OS error 60, "Operation timed out"
There was a problem connecting to the server
When I execute tsql -C, I get:
Compile-time settings (established with the "configure" script)
Version: freetds v0.91
freetds.conf directory: /usr/local/php5/etc
MS db-lib source compatibility: yes
Sybase binary compatibility: no
Thread safety: yes
iconv library: yes
TDS version: 5.0
iODBC: no
unixodbc: no
SSPI "trusted" logins: no
Kerberos: no
But there's no freetds.conf file in /usr/local/php5/etc, ¿Is there a way to change the route to freetds.conf file? I have tried uninstalling FreeTDS with brew uninstall freetds but when I type tsql -C I still having the same response.
I check my phpinfo() and maybe this it's generating conflicts
There are several ways to do this, but the easiest is to put a .freetds.conf in your home directory. On a Mac, that'd be /Users/username/.freetds.conf.
It will be read before the system wide configuration if it exists. Reference: http://www.freetds.org/userguide/freetdsconf.htm
Machine 1:
>tsql -C
Compile-time settings (established with the "configure" script)
Version: freetds v0.91.90
freetds.conf directory: /etc
MS db-lib source compatibility: no
Sybase binary compatibility: no
Thread safety: yes
iconv library: yes
TDS version: 4.2
iODBC: no
unixodbc: yes
SSPI "trusted" logins: no
Kerberos: no
I have the freeTDS installed and able to make a connection to the mssql,
> TDSVER=4.2 tsql -S xx.xx.xxx.xxx -U xxxx -P xxxx -p 1433
locale is "en_US.UTF-8"
locale charset is "UTF-8"
using default charset "UTF-8"
1>
So, when i try connecting from TinyTds, it is throwing the below error,
Adaptive server is unavailable or does not exist
Machine 2:
The configuration is same as in the machine 1, and from this machine, it is connecting to the mssql with TinyTds
>tsql -C
Compile-time settings (established with the "configure" script)
Version: freetds v0.91.90
freetds.conf directory: /etc
MS db-lib source compatibility: no
Sybase binary compatibility: no
Thread safety: yes
iconv library: yes
TDS version: 4.2
iODBC: no
unixodbc: yes
SSPI "trusted" logins: no
Kerberos: no
I have the freeTDS installed and able to make a connection to the mssql,
> TDSVER=4.2 tsql -S xx.xx.xxx.xxx -U xxxx -P xxxx -p 1433
locale is "en_US.UTF-8"
locale charset is "UTF-8"
using default charset "UTF-8"
1>
Able to connect to the server using TinyTds
I am not sure why this is happening or where to check and i don't think it is a firewall issue as i am able to connect from the terminal, also i have verified its credentials etc., all are same except that the connection is unsuccessful. Any help much appreciated!
Note: The scenario is,
I am running a test through jenkins, where it is running the ruby process using the slave 'machine1', where it is not able to connect to the sqlserver(having freetds configured) throwing Adaptive server unavailable or does not exist error.
when i modify the slave to 'machine2', it is establishing the connection, despite having the same freetds configuration as machine1
My problem was resolved after I enabled port 1433 on all connections
I'm trying to connect to a MSSQL 2005 server using FreeTDS.
But I'm getting the "Login failed for user" error. There is a section on it in the FreeTDS manual trouble shooting section. But it does not mention any possible errors related to it. Can it be an issue with my tsql connection string? Or is it something misconfigured on the MSSQL side?
I am able to connect to the SQL Server Management using the same credentials.
This is what I am using and the output (I've removed the ipnumber and username):
$ TDSVER=4.2 tsql -H <ipnumber> -p 1433 -U <username>
Password:
locale is "en_US.UTF-8"
locale charset is "UTF-8"
using default charset "UTF-8"
Msg 18456 (severity 14, state 1) from PS136 Line 1:
"Login failed for user '<username>'."
Error 20002 (severity 9):
Adaptive Server connection failed
There was a problem connecting to the server
And my compile time settings:
$ tsql -C
Compile-time settings (established with the "configure" script)
Version: freetds v0.91
freetds.conf directory: /etc/freetds
MS db-lib source compatibility: no
Sybase binary compatibility: yes
Thread safety: yes
iconv library: yes
TDS version: 4.2
iODBC: no
unixodbc: yes
SSPI "trusted" logins: no
Kerberos: no
I'm on Ubuntu 12.04 and I installed FreeTDS like so:
$sudo apt-get install freetds-common freetds-bin tdsodbc
Turned out I had been given the wrong port number. I also needed to specify the instance in the freetds config file.
I also use freetds to connect to SQL Server 2012.
I have this section in my freetds.conf file
[mycomp]
host = some.ipnumber.or.hostname
port = 1433
client charset = UTF-8
tds version = 8.0
Then I connect with sqsh (isql replacement, also in the ubuntu repos)
sqsh -I /etc/freetds/freetds.conf -Smycomp -Uknb -Psecrit
This is my tsql -C output
○ → tsql -C
Compile-time settings (established with the "configure" script)
Version: freetds v0.91
freetds.conf directory: /etc/freetds
MS db-lib source compatibility: no
Sybase binary compatibility: yes
Thread safety: yes
iconv library: yes
TDS version: 4.2
iODBC: no
unixodbc: yes
SSPI "trusted" logins: no
Kerberos: yes
While trying to connect remote SQL Server:
$tsql -S localhost -U myuser
I got error like:
locale is "en_US.UTF-8"
locale charset is "UTF-8"
using default charset "UTF-8"
Error 20009 (severity 9):
Unable to connect: Adaptive Server is unavailable or does not exist
OS error 61, "Connection refused"
There was a problem connecting to the server
The output of $tsql -C is as below:
Compile-time settings (established with the "configure" script)
Version: freetds v0.91
freetds.conf directory: /usr/local/freetds/conf/freetds
MS db-lib source compatibility: no
Sybase binary compatibility: no
Thread safety: yes
iconv library: no
TDS version: 5.0
iODBC: no
unixodbc: no
SSPI "trusted" logins: no
Kerberos: no
I have created tunnel for remote server like:
$ssh -L 1433:db_server:1433 user#mid_server
This forward the local port 1433 to db_server. I tested. My ssh tunnel works because I can connect to database using Navicat (localhost on 1433). I can telnet localhost on port 1433.
I kinda get it worked by modifying freetds.conf
from
[global]
# TDS protocol version
; tds version = 4.2
to
[global]
# TDS protocol version
tds version = 7.0
This worked for me with ASE 16.0 installed and running on Ubuntu 14.04 LTS, both client and server.
SERVER: Make sure there is an entry in /etc/hosts of your server (sybaseServer). In a standard Ubuntu 14.04 installation you will not find this, but "127.0.1.1 sybaseServer". But sybase seems depends on it.
/etc/hosts
...
192.168.1.100 sybaseServer
...
CLIENT: The entry in freetds.conf is
[SYBASE]
host = 192.168.1.100
port = 5000
tds version = 5.0
Now you can connect to your server:
$tsql -S SYBASE -U sa
obviously you have to replace IP-address, servername etc. with your own data