Unable to connect SQL Server with ODBC drivers on linux - sql-server

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

Related

Connect host machine's SQL Server 2017 from homestead vagrant

I'm trying to connect my local/host machine SQL Server from Laravel vagrant homestead. I've been googling all day trying to connect the host machine's database installing different PHP packages but so far have no lucks. I thought I would remove PHP at this point and try to establish the connection inside homestead using sqlcmd instead.
So, I have installed sqlcmd in homestead and tried to execute the following command to connect to the host machine's database.
sqlcmd -S 10.0.2.2,1433 -U sa -P 'password' -Q "sp_databases"
However, I received the following error:
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Client unable to establish connection because an error was encountered during handshakes before login. Common causes include client attempting to connect to an unsupported version of SQL Server, server too busy to accept new connections or a resource limitation (memory or maximum allowed connections) on the server..
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : TCP Provider: Error code 0x2746.
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Client unable to establish connection.
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Client unable to establish connection due to prelogin failure.
However, If I use sqlcmd on my host machine and execute the following command, I am able to access the database.
sqlcmd -S LAPTOP-ACQES\MSSQL2017 -U sa -P Asdf1234 -Q "sp_databases"
In my Homestead.yaml, I have set up port forwarding from:
ports:
- send: 1433
to: 1433
You say this doesn't work:
sqlcmd -S 10.0.2.2,1433 -U sa -P 'password' -Q "sp_databases"
Yet this does:
sqlcmd -S LAPTOP-ACQES\MSSQL2017 -U sa -P Asdf1234 -Q "sp_databases"
In the former, you are using the IP, but no instance name.
Try:
sqlcmd -S 10.0.2.2\MSSQL2017 -U sa -P 'password' -Q "sp_databases"
Also:
Ensure TCP/IP is enabled in SQL Network Configuration.
Verify SQL Server Browser is running.
Allow remote connections in SQL Server properties.
Lock SQL Network configuration to port 1433 on all adapters, and disable dynamic ports (then restart services).

Remote connection to SQL Server with FreeTDS and IPv6

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.

Connecting to MonetDB using ODBC

I have tried using unixODBC (version 2.3.2) and the MonetDB ODBC client (version 11.21.5) on both Mac OS X 10.9 and Debian 8, but cannot connect through ODBC using isql on client machines to a MonetDB server running on Debian 8, although it works fine from the server machine.
When issuing isql -v voc on the client machines I get the following error message:
[08001][unixODBC][MonetDB][ODBC Driver 11.21.5]Client unable to establish connection
[ISQL]ERROR: Could not SQLConnect
Here is my .odbc.ini file:
[voc]
Driver = MonetDB
Description = MonetDB voc test database
Servername = <<left out>>
Port = 50000
UserName = monetdb
Password = monetdb
Database = voc
and my /opt/local/etc/odbcinst.ini file:
[MonetDB]
Description = ODBC Driver for MonetDB SQL Server
Driver = /usr/local/monetdb/lib/libMonetODBC.so
Setup = /usr/local/monetdb/lib/libMonetODBCs.so
FileUsage = 1
Interestingly enough I am able to connect using mclient from client machines and the server machine as well using the following command line:
mclient -d voc -u monetdb -h <<left out>>
The server is configured as follows:
monetdbd get all testing/testDBfarm/
property value
hostname <<left out>>
dbfarm testing/testDBfarm/
status monetdbd[37007] 1.7 (Jul2015) is serving this dbfarm
mserver /usr/bin/mserver5
logfile testing/testDBfarm//merovingian.log
pidfile testing/testDBfarm//merovingian.pid
sockdir /tmp
port 50000
exittimeout 60
forward proxy
discovery true
discoveryttl 600
control no
passphrase <unknown>
mapisock /tmp/.s.monetdb.50000
controlsock /tmp/.s.merovingian.50000
Is there anything I am missing here which is needed to let clients connect to a MonetDB server through ODBC?
The debug log of isql (running ODBCDEBUG=/tmp/odbclog isql test) revealed the problem:
The MonetDB ODBC driver has ignored the Servername parameter in my config file.
.odbc.ini:
Servername = LEFT OUT
Log:
SQLConnect: DSN=voc UID=monetdb PWD=monetdb host=localhost port=50000 database=voc.
It is quite unfortunate, that most ODBC drivers use a different name for specifying the server's hostname or IP-address: Servername, Host, or even Server (See: http://www.unixodbc.org/odbcinst.html)
Thus, for MonetDB's ODBC driver we need to use Host to specify the hostname, instead of Servername or Server, as for Postgres or MySQL, e.g.

FreeTDS hangs indefinitely after Microsoft SQL Express 2012 Install

FreeTDS hangs indefinitely when I try to connect to a server:
C:\FreeTDS\bin>tsql -H localhost -p 1433
locale is "English_United States.1252"
locale charset is "CP1252"
using default charset "CP1252"
(nothing else is displayed, can only exit with ^C)
Identical behaviour occurs when I run tsql -S <servername>.
I recently uninstalled Microsoft SQL Server Management Studio, and then installed the Express edition. Connection with tsql -H localhost -p 1433 worked before the uninstall/install.
Running tsql -C yields:
Compile-time settings (established with the "configure" script)
Version: freetds v0.91.98
freetds.conf directory: /mingw/etc
MS db-lib source compatibility: no
Sybase binary compatibility: no
Thread safety: yes
iconv library: yes
TDS version: 7.0
iODBC: no
unixodbc: yes
SSPI "trusted" logins: yes
Kerberos: yes (Heimdal 1.5.3)
SSL encryption: yes (OpenSSL 1.0.1e)
Some more information:
I have the folowing SQL-related services running:
SQL Full-Text Filter Daemon Launcher (SQLEXPRESS)
SQL Server (SQLEXPRESS)
SQL Server Browser
SQL Server Reporting Services (SQLEXPRESS)
SQL Server VSS Writer
I have tried reinstalling FreeTDS.
I have enabled TCP/IP for SQLEXPRESS in the Sql Server Configuration Manager.
The tsql command was hanging because the server was not running on the default port. I found this out by running C:\>netstat -na | find "1433", which showed nothing LISTENING on port 1433.
This is how I fixed the problem:
Open "Sql Server Configuration Manager"
Go to "SQL Server Network Configuration > Protocols for SERVER"
Right click "TCP/IP", select "Properties", go to the "IP Addresses" tab
Under "IPAll" set "TCP Port" to the desired port number
Click OK, and restart the SQL Server service.

How to pass instance in freetds - Ubuntu

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).

Resources