isql error: Could not sql connect in Zabbix appliance - sql-server

I want to monitor the data in a Microsoft SQL Server database using Zabbix by ODBC and without agent. I have installed ODBC on Zabbix appliance (VMware).
When I enter command isql test, I get error:
Could not SQL connect.
Also in Zabbix front dashboard there is a problem: SQL Server could not fetch info data. The settings of my odbc.ini and odbcinst.ini files are as below:
odbc.ini:
[mssql]
Description: mssql database connected to zabbix
Driver= ODBC Driver 17 for SQL Server
Server= the ip of database server
User= my username in database server
Password= my password in database server
Port= 1433
Database= database name
odbcinst.ini:
[ODBC Driver 17 for SQL Server]
Description= Microsoft ODBC Driver 17 for SQL Server
Driver = /opt/microsoft/msodbcsql17/lib64/libmsodbcsql-17.7.so.2.1

You should use verbose mode :
-v Turn on the verbose mode, where the errors are fully described. Useful for debugging.
And specify the DSN you want to connect to:
isql –v your_DSN
This should be enough to pinpoint the cause of the connection error.

I had the same problem.
[ZPRX-UAT ~]$ isql mssqltest -v
[28000][unixODBC][Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Login failed for user ''.
[ISQL]ERROR: Could not SQLConnect
In my case it helped to remove the user and password in the /etc/odbc.ini file.
Then, using the isql command with the -v parameter and a user with a password. The isql command ended correctly in my case.
[ZPRX-UAT ~]$ isql -v mssqltest Test Test123
+---------------------------------------+
| Connected! |
| |
| sql-statement |
| help [tablename] |
| quit |
| |
+---------------------------------------+
SQL>

Related

SA default password SQL Server on Linux

I installed SQL Server 2017 on Linux on a CentOS 7 derivate. Now I want to login with the command: "sqlcmd -S 172.0.0.1 -U SA". But I never set up a password. How am I able to login to the SQL Server? Root password is also not working. Could it be that the problem is somewhere earlier?
I tried as well to connect with "root", "sa" and the root password, also with Blank password and "Password123", according to old default passwords.
sqlcmd -S 127.0.0.1 -U sa
I get the following error:
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Login timeout expired.
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : TCP Provider: Error code 0x2749.
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : A network-related or instance-specific error hasile establishing a connection to SQL Server. Server is not found or not accessible. Check if instance nam and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online.

Not able to connect to MS SQL DB instance with ms sql driver 13 from Linux 7(CentOS7) Env

I am trying to connect from Linux virtual environment to MS SQL Server instance using ms sql driver 13.
[<user> ~]$ which odbcinst
/usr/bin/odbcinst
[<user> ~]$ odbcinst -j
unixODBC 2.3.1
DRIVERS............: /etc/odbcinst.ini
SYSTEM DATA SOURCES: /etc/odbc.ini
FILE DATA SOURCES..: /etc/ODBCDataSources
USER DATA SOURCES..: /home/<user>/.odbc.ini
SQLULEN Size.......: 8
SQLLEN Size........: 8
SQLSETPOSIROW Size.: 8
[<user> ~]$ cat /etc/odbc.ini
[DNSname-1]
Driver = ODBC Driver 13 for SQL Server
SERVER=server-1
DATABASE=DB1
[DNSname-2]
Driver = ODBC Driver 13 for SQL Server
SERVER=server-2\instance-1
Database=DB2
[<user> ~]$ isql DNSname-1 userid1 passwd1
+---------------------------------------+
| Connected! |
| |
| sql-statement |
| help [tablename] |
| quit |
| |
+---------------------------------------+
SQL> quit
isql is able to connect to ms sql server
[<root> ~]$ isql -v DNSname-2 userid2 passwd2
[S1T00][unixODBC][Microsoft][ODBC Driver 13 for SQL Server]Login timeout expired
[08001][unixODBC][Microsoft][ODBC Driver 13 for SQL Server]MAX_PROVS: Error Locating Server/Instance Specified [xFFFFFFFF].
[08001][unixODBC][Microsoft][ODBC Driver 13 for SQL Server]A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online.
[ISQL]ERROR: Could not SQLConnect
But When I try to connect to sql db instance, isql is giving an error as "Login timeout expired"

Unix ODBC Connect 2016 MS SQL Server sql state 28000 native error 18456

I can connect ms sql server on windows desktop using ODBC and I got into the issue when using Linux. ODBC drivers are already installed just that I couldn't connect. I search on the internet and most posts are saying it's windows authentication issue. I set the Trusted_Connection=No and enter UID/PWD in isql -v MSSQL [UID] [PWD].
It gives me the error saying:
[28000][unixODBC][Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Login failed for user 'UID'.
[ISQL]ERROR: Could not SQLConnect
The ODBC config file:
[root#IRISOEL01 etc]# cat odbcinst.ini
[ODBC]
Trace = Yes
TraceFile = /tmp/trace.log
[ODBC Driver 13 for SQL Server]
Description=Microsoft ODBC Driver 13 for SQL Server
Driver=/opt/microsoft/msodbcsql/lib64/libmsodbcsql-13.0.so.1.0
UsageCount=3
[root#IRISOEL01 etc]# cat odbc.ini
[MSSQL]
Driver=ODBC Driver 13 for SQL Server
Server=server_address
Database=master
AnsiNPW=Yes
QuotedId=Yes
AutoTranslate=Yes
Trusted_Connection=No
Encrypt=No
I just can tell you to try using in odbc.ini the name of the driver you configured in odbcinst.ini
Driver=ODBC
After adding the driver path in odbcinst.ini, for example I use this odbcinst.ini
[SQLServer]
Description=Microsoft SQL Server ODBC Driver V1.0 for Linux
Driver=/opt/microsoft/sqlncli/lib64/libsqlncli-11.0.so.1790.0
Threading=1
UsageCount=1
then in odbc.ini
[source]
Driver=SQLServer
Description=ODBC Database Connection
Trace=No
Server=192.168.1.25,1433
Database=dbname

[unixODBC][FreeTDS][SQL Server]Unable to connect to data source

Im using Debian machine and I was trying to connect to remote sql server, but encounter the error when I try to connect via isql:
root#debian:~/installtest# isql -v SQLServer-Conn
[S1000][unixODBC][FreeTDS][SQL Server]Unable to connect to data source
[37000][unixODBC][FreeTDS][SQL Server]Login failed for user ''.
[ISQL]ERROR: Could not SQLConnect
Here is my odbc.ini
[SQLServer-Conn]
Description=MS SQL connection to remote db
Driver=FreeTDS
Server=10.xx.xx.xx
Port=49xxx
User=username
Password=password
Database=remotedb
Trace=No
Here is my odbcinst.ini
[FreeTDS]
Description = ODBC for SQL Srv
Driver = /usr/lib/i386-linux-gnu/odbc/libtdsodbc.so
Setup = /usr/lib/i386-linux-gnu/odbc/libtdsS.so
UsageCount = 1
The db was fine as I was able to connect using this same machine via tsql command. So i'm not sure if im missing something on the .ini files
Thanks for the help
You need to pass isql a username and password in addition to your DSN.
isql -v SQLServer-Conn username password
Give that a try - good luck!

unixODBC connecting to SQL server timeout

I am having issue with unixODBC. I need multiple connections to different Sql server instances and all of them are working except one. It has additional parameter in host.
All host are ip or just host name, but one which is ont working has IP\smth
I have tried:
Description=Microsoft ODBC Driver 13 for SQL Server
Driver=/opt/microsoft/msodbcsql/lib64/libmsodbcsql-13.0.so.0.0
Database=dbname
Server=192.168.1.1/PARAM
Port=1433
Also tried escaping, quotes, etc.
isql -v returns:
[S1T00][unixODBC][Microsoft][ODBC Driver 13 for SQL Server]Login timeout expired
[08001][unixODBC][Microsoft][ODBC Driver 13 for SQL Server]MAX_PROVS: Error Locating Server/Instance Specified [xFFFFFFFF].
[08001][unixODBC][Microsoft][ODBC Driver 13 for SQL Server]A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online.
[ISQL]ERROR: Could not SQLConnect
I could connect from MAC OSX (Sierra) via unixODBC to SQL Server 2017 (installed in a docker container using this image: https://hub.docker.com/r/microsoft/mssql-server-linux/) by following these steps:
Install the ODBC driver as described here: https://learn.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server
Find out in which odbc.ini config file the system DSNs are stored and where to find the ODBC driver name:
odbcinst -j
...
DRIVERS............: /usr/local/etc/odbcinst.ini
SYSTEM DATA SOURCES: /usr/local/etc/odbc.ini
...
Remember the exact driver name from the odbcinst.ini file (preconfigured from the driver installation from step 1):
...
[ODBC Driver 13 for SQL Server]
...
Edit the odbc.ini file and add a DSN to your database (all allowed keywords are described here: https://learn.microsoft.com/en-us/sql/connect/odbc/linux-mac/connection-string-keywords-and-data-source-names-dsns):
...
[MSSQLTest]
Driver = ODBC Driver 13 for SQL Server
Server = 192.168.178.1,1433
...
Note: Use your server IP address (or server name) and port number here.
Test the connection (it should work now):
isql MSSQLTest sa Password12345 -v
Note: Replace the user name "sa" and the password "Password12345" with your own credentials!
You should see then:
Connected!
Enjoy your hot caffeinated beverage ;-)

Resources