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
Related
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'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
I've decided to use FreeTDS driver and unixODBC to manage the PDO connection between my LAMP-based app with a remote MsSQL database.
unfortunately it appears that the driver doesn't read the freetds.conf file, nor the environmental variables set either directly via server's CLI or specified in php file by putenv() function.
now some data:
as I ping the server - no packets are lost.
as I telnet the server on 1433 port - the connection is established
as I use the command
TDSVER=7.0 tsql -H >IP< -p 1433 -U username
I am prompted to enter password and connection is established.
without the TDSVER preceding the command - the connection fails with such a message:
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
the tsql -C commands echos such an output:
Compile-time settings (established with the "configure" script)
Version: freetds v0.91
freetds.conf directory: /usr/local/etc
MS db-lib source compatibility: yes
Sybase binary compatibility: no
Thread safety: yes
iconv library: yes
TDS version: 5.0
iODBC: no
unixodbc: yes
SSPI "trusted" logins: no
Kerberos: no
freetds.conf in the location given above has this entry:
[MSSQL]
host = >IP<
port = 1433
tds version = 7.0
the ISQL also fails:
isql -v MSSQL
[S1000][unixODBC][FreeTDS][SQL Server]Unable to connect to data source
[01000][unixODBC][FreeTDS][SQL Server]Adaptive Server connection failed
[ISQL]ERROR: Could not SQLConnect
my odbc.ini :
[MSSQL]
Description = MS SQL Server
Driver = FreeTDS
TDS_Version = 7.0
Server = >IP<
UID = username
PWD = password
ReadOnly = No
Port = 1433
I suppose the solution is really simple, but i'm just too stupid to find it...
I spent a long time today debugging a similar problem. I had set "TDS version" in freetds.conf but it was not being used in my ODBC connection. After reading the freetds source code (connectparams.c:odbc_parse_connect_string) I discovered that:
If your connection string uses "SERVER=" then both freetds.conf and odbc.ini are ignored
If your connection string uses "SERVERNAME=" then the settings in the appropriate freetds.conf server are used
If your connection string uses "DSN=" then the settings in the appropriate odbc.ini DSN are used
odbcinst.ini is a red herring. FreeTDS never checks that for settings.
The settings you specify in the connection string are always respected. It also always respects the environment variables like TDSVER.
My gut instinct is you need to change your tds version = 7.0 to tds version = 8.0 in your freetds.conf and odbc.ini files AND you need something in your odbcinst.ini file. Here's what I've got working on an Ubuntu 12.04 server talking to a remote MSSQL server:
freetds.conf
# Define a connection to the MSSQL server.
[mssql]
host = myserver
port = 1433
tds version = 8.0
odbc.ini
# Define a connection to the MSSQL server.
# The Description can be whatever we want it to be.
# The Driver value must match what we have defined in /etc/odbcinst.ini
# The Database name must be the name of the database this connection will connect to.
# The ServerName is the name we defined in /etc/freetds/freetds.conf
# The TDS_Version should match what we defined in /etc/freetds/freetds.conf
[mssql]
Description = MSSQL Server
Driver = freetds
Database = MyDB
ServerName = myserver
TDS_Version = 8.0
odbcinst.ini
# Define where to find the driver for the Free TDS connections.
[freetds]
Description = MS SQL database access with Free TDS
Driver = /usr/lib/i386-linux-gnu/odbc/libtdsodbc.so
Setup = /usr/lib/i386-linux-gnu/odbc/libtdsS.so
UsageCount = 1
I experienced this exact same problem, but my config was already correctly set up. The problem was that the TDS versions that freetds.conf recognizes has changed in newer versions, but apparently the old versions still work in the TDSVER environment variable. Once I set the version in the config files to 7.1 rather than 8.0 everything started working.
The initial TDSVER=7.0 issue was resolved by adding the following at the end of my odbc.ini file:
[Default]
Driver=/usr/local/lib/libtdsodbc.so
Instead of connecting to an IP, try to connect to the name of the configuration section? For example:
isql -v MSSQL