Data source name not found and no default driver specified - Zabbix - sql-server

I am trying to monitor an MSSQL database via ODBC with Zabbix, but I was getting an error that my DSN is invalid, even after performing several tests, does anyone have any idea what it could be?
/etc/freetds.conf
[MSSQL_SERVER]
host = <ip>
port = 1433
tds version = 8.0
/etc/odbcinst.ini
[FreeTDS]
Description= FreeTDS Driver for Linux & MSSQL
Setup= /usr/lib64/libtdsodbc.so.0
Driver = /usr/lib64/libtdsodbc.so.0
UsageCount=1
/etc/odbc.ini
[MSSQL]
Driver = FreeTDS
Servername = MSSQL_SERVER
isql DSN
[root#zabbix]# isql MSSQL sa <password>
+---------------------------------------+
| Connected! |
| |
| sql-statement |
| help [tablename] |
| quit |
| |
+---------------------------------------+
SQL> quit
tsql Servername
[root#zabbix]# tsql -S MSSQL_SERVER -U sa -P <password>
locale is "en_US.UTF-8"
locale charset is "UTF-8"
using default charset "UTF-8"
1> quit
tsql conf
[root#zabbix]# tsql -C
Compile-time settings (established with the "configure" script)
Version: freetds v1.1.20
freetds.conf directory: /etc
MS db-lib source compatibility: yes
Sybase binary compatibility: yes
Thread safety: yes
iconv library: yes
TDS version: auto
iODBC: no
unixodbc: yes
SSPI "trusted" logins: no
Kerberos: yes
OpenSSL: no
GnuTLS: yes
MARS: yes
Error: Cannot connect to ODBC DSN: [SQL_ERROR]:[IM002][0][[unixODBC][Driver Manager]Data source name not found and no default driver specified]
Template:

Related

freetds connection issue macOS

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)

TinyTds - Adaptive server is unavailable or does not exist

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

Connect to MSSQL database with arm linux board using unixODBC and FreeTDS problems

I am having problems to query a remote MSSQL database from my arm linux board.
I compiled unixODBX and FreeTDS, copied all files to the arm board with the same path as in the Ubuntu machine where they where compiled.
I also compiled everything for the Ubuntu machine.
In the Ubuntu machine I can connect and query the database with tsql and isql.
In the arm board I can only connect and query with tsql, not with isql.
COMPILATION FOR THE ARM BOARD IN THE UBUNTU MACHINE:
unixODBX:
./configure --prefix=/usr/local/unixodbc-arm --host=arm-linux
make
make install
I removed /usr/local/unixodbc-arm/bin/odbc_config otherwise I could´t compile it.
FreeTDS:
./configure --prefix=/usr/local/freetds-arm --with-unixodbc=/usr/local/unixodbc-arm --host=arm-linux --disable-libiconv
make
make all
I used --disable-libiconv because without this option was not working.
Than I copied the files in the "bin", "lib" and "etc" directories to the arm board with the same path as in the Ubuntu machine.
/usr/local/unixodbc-arm/bin
/usr/local/unixodbc-arm/lib
/usr/local/unixodbc-arm/etc
/usr/local/freetds-arm/bin
/usr/local/freetds-arm/lib
/usr/local/freetds-arm/etc
The configuartion files are as follows:
freetds.conf:
root#ok335x:/# cat /usr/local/freetds-arm/etc/freetds.conf
# $Id: freetds.conf,v 1.12 2007-12-25 06:02:36 jklowden Exp $
#
# This file is installed by FreeTDS if no file by the same on a multi-user system
# name is found in the installation directory.
#
# For information about the layout of this file and its settings,
# see the freetds.conf manpage "man freetds.conf".
# Global settings are overridden by those in a database
# server specific section
[global]
# TDS protocol version
; tds version = 4.2
# Whether to write a TDSDUMP file for diagnostic purposes
# (setting this to /tmp is insecure on a multi-user system)
; dump file = /tmp/freetds.log
; debug flags = 0xffff
# Command and connection timeouts
; timeout = 10
; connect timeout = 10
# If you get out-of-memory errors, it may mean that your client
# is trying to allocate a huge buffer for a TEXT field.
# Try setting 'text size' to a more reasonable limit
text size = 64512
# A typical Sybase server
[egServer50]
host = symachine.domain.com
port = 5000
tds version = 5.0
# A typical Microsoft server
[egServer70]
host = ntmachine.domain.com
port = 1433
tds version = 7.0
# Microsoft SQL Server
[SQLEXPRESS]
host = 192.168.0.195
port = 1433
tds version = 7.0
client charset = UTF-8
root#ok335x:/#
odbcinst.ini:
root#ok335x:/# cat /usr/local/unixodbc-arm/etc/odbcinst.ini
[FreeTDS]
Description=TDS driver (Sybade/MS SQL)
Driver=/usr/local/freetds-arm/lib/libtdsodbc.so
UsageCount=2
root#ok335x:/#
odbc.ini
root#ok335x:/# cat /usr/local/unixodbc-arm/etc/odbc.ini
[SQLEXPRESS]
Description = Test to FreeTDS
Driver = FreeTDS
Trace = Yes
TraceFile = sql.log
Database = gti
Servername = SQLEXPRESS
UserName = gti_monitor
Password = gti_monitor
Port = 1433
ReadOnly = No
RowVersioning = No
ShowSystemTables = No
ShowOidColumn = No
FakeOidIndex = No
ConnSettings =
root#ok335x:/#
tsql configuration:
root#ok335x:/# tsql -C
Compile-time settings (established with the "configure" script)
Version: freetds vdev.0.99.134
freetds.conf directory: /usr/local/freetds-arm/etc
MS db-lib source compatibility: no
Sybase binary compatibility: no
Thread safety: yes
iconv library: no
TDS version: 5.0
iODBC: no
unixodbc: yes
SSPI "trusted" logins: no
Kerberos: no
OpenSSL: no
GnuTLS: no
root#ok335x:/#
odbcinst configuration:
root#ok335x:/# odbcinst -j
unixODBC 2.3.4
DRIVERS............: /usr/local/unixodbc-arm/etc/odbcinst.ini
SYSTEM DATA SOURCES: /usr/local/unixodbc-arm/etc/odbc.ini
FILE DATA SOURCES..: /usr/local/unixodbc-arm/etc/ODBCDataSources
USER DATA SOURCES..: /home/root/.odbc.ini
SQLULEN Size.......: 4
SQLLEN Size........: 4
SQLSETPOSIROW Size.: 2
root#ok335x:/#
Running tsql:
root#ok335x:/# tsql -S SQLEXPRESS -U gti_monitor -P gti_monitor
locale is "C"
locale charset is "ANSI_X3.4-1968"
using default charset "UTF-8"
1> select * from pressures
2> go
id datetime press1 press2
NULL NULL 1 2
(1 row affected)
1> quit
root#ok335x:/#
Running isql:
root#ok335x:/# isql SQLEXPRESS gti_monitor gti_monitor -v
[S1000][unixODBC][FreeTDS][SQL Server]Unable to connect to data source
[ISQL]ERROR: Could not SQLConnect
root#ok335x:/#
These commands are both working in the Ubuntu machine with the same configuration files.
Can anyone help on that?
Thank you very much.
From the isql man page...
isql DSN [USER [PASSWORD]] [options]
DSN. The Data Source Name, which should be used to make connection to the database. The data source is looked for in the /etc/odbc.ini and $HOME/.odbc.ini files in that order, with the latter overwriting the former.
Tsql with -S is using your freetds.conf file. But it looks like you have the odbc.ini file in /usr/local/unixodbc-arm/etc/odbc.ini

ubuntu tsql working and isql not working

I'm trying to connect MSSQL server to ubuntu 14.04 with FreeTDS and unixODBC.
I can connect using tsql with:
~$ tsql -S MSSQL -U <username> -P <password>
This works correctly.
When trying to use isql i get the following
isql -v MSSQL <username> <password>
[S1000][unixODBC][FreeTDS][SQL Server]Unable to connect to data source
[ISQL]ERROR: Could not SQLConnect
Here are my configs.
odbc.ini
[MSSQL]
Driver = FreeTDS
TDS_Version = 8.0
Server = <server>
Instance = dev
Database = <database>
odbcinst.ini
[FreeTDS]
Description = FreeTDS
Driver = /usr/local/lib/libtdsodbc.so
Setup = /usr/local/lib/libtdsodbc.so
Trace = Yes
TraceFile = /tmp/freetds.log
ForceTrace = Yes
freetds.conf
# $Id: freetds.conf,v 1.12 2007/12/25 06:02:36 jklowden Exp $
#
# This file is installed by FreeTDS if no file by the same
# name is found in the installation directory.
#
# For information about the layout of this file and its settings,
# see the freetds.conf manpage "man freetds.conf".
# Global settings are overridden by those in a database
# server specific section
[global]
# TDS protocol version
# tds version = 4.2
# Whether to write a TDSDUMP file for diagnostic purposes
# (setting this to /tmp is insecure on a multi-user system)
; dump file = /tmp/freetds.log
; debug flags = 0xffff
# Command and connection timeouts
; timeout = 10
; connect timeout = 10
# If you get out-of-memory errors, it may mean that your client
# is trying to allocate a huge buffer for a TEXT field.
# Try setting 'text size' to a more reasonable limit
text size = 64512
# A typical Sybase server
[egServer50]
host = symachine.domain.com
port = 5000
tds version = 5.0
# A typical Microsoft server
[egServer70]
host = ntmachine.domain.com
port = 1433
tds version = 7.0
[MSSQL]
host = <host>
instance = dev
tds version = 8.0
I think the issue is being caused by the driver, I don't believe i should get an error saying the driver isn't executable. here is the osql output:
osql -S MSSQL -U <username> -P <password>
checking shared odbc libraries linked to isql for default directories...
strings: '': No such file
trying /tmp/sql ... no
trying /tmp/sql ... no
trying /etc ... OK
checking odbc.ini files
reading /home/<user>/.odbc.ini
[MSSQL] found in /home/<user>/.odbc.ini
found this section:
[MSSQL]
Driver = FreeTDS
TDS_Version = 8.0
Server = <server>
Database = <database>
looking for driver for DSN [MSSQL] in /home/<user>/.odbc.ini
found driver line: " Driver = FreeTDS"
driver "FreeTDS" found for [MSSQL] in .odbc.ini
found driver named "FreeTDS"
"FreeTDS" is not an executable file
looking for entry named [FreeTDS] in /etc/odbcinst.ini
found driver line: " Driver = /usr/local/lib/libtdsodbc.so"
found driver /usr/local/lib/libtdsodbc.so for [FreeTDS] in odbcinst.ini
/usr/local/lib/libtdsodbc.so is an executable file
"Server" found, not using freetds.conf
Server is <server_name>
Configuration looks OK. Connection details:
DSN: MSSQL
odbc.ini: /home/<user>/.odbc.ini
Driver: /usr/local/lib/libtdsodbc.so
Server hostname: <host>
Address: <ip_address>
Attempting connection as <username> ...
+ isql MSSQL <username> <password> -v
[S1000][unixODBC][FreeTDS][SQL Server]Unable to connect to data source
[ISQL]ERROR: Could not SQLConnect
Any help is appreciated, Thanks.
I found the answer to my question. I needed to add the instance to the server in the odbc.ini file like so
MSSQL]
Driver = FreeTDS
TDS_Version = 8.0
Server = <server\dev>
Database = <database>
This let me execute isql.

FreeTDS: Login failed for user

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

Resources