I'm trying to connect Redhat Linux to a Microsoft SQL Server 2008. I already had trouble setting it up on windows (my test machine) but now I need to deploy it on the Linux machine where it will be in production.
So I've installed unixODBC and FreeTDS (with a lot of effort, not even sure if it was installed correctly :S), and the outcome of that is that I have 3 files in /usr/local/etc:
odbc.ini
odbcinst.ini
freetds.conf
I then edited the freetds.conf file and this is what I added:
[sqlServer]
host = servername
port = 4113
instance = sqlServer
tds version = 8.0
client charset = UTF-8
I had to find out the port number from my DBA, as it is set to dynamic in SQL Server 2008.
My odbcinst.ini file looks like this:
[FreeTDS]
Description = TDS driver (Sybase/MS SQL)
Driver = /usr/local/lib/libtdsodbc.so
Setup = /usr/local/lib/libtdsS.so
CPTimeout =
CPReuse =
FileUsage = 1
and my odbc.ini files looks like this:
[sqlServer]
Driver = FreeTDS
Description = ODBC connection via FreeTDS
Trace = 1
Servername = sqlServer
Database = RubyApp
So now I tried connecting to see if there is any connection by using
tsql -S sqlServer -U test -P test,
however that only gives me the following error:
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
When I tried using isql, doing isql -v sqlServer test test, that spat out the following error:
[S1000][unixODBC][FreeTDS][SQL Server]Unable to connect to data source
[01000][unixODBC][FreeTDS][SQL Server]Unknown host machine name.
[ISQL]ERROR: Could not SQLConnect
Any ideas what I could be doing wrong?
If you cannot connect with tsql, then there is a connection issue with your SQL server or in freetds.conf.
First verify the port and named instance using tsql -LH [SQL server IP]
# tsql -LH 127.0.0.1
ServerName HOME
InstanceName INSTANCE1
IsClustered No
Version 10.50.2500.0
tcp 1434
If this doesn't work, there is a connection issue between your server and the SQL server.
If it does work, then set your port to match tcp above in freetds.conf.
[TDS]
host = 127.0.0.1
port = 1434
tds version = 7.0
Instance is set in your odbc.ini
[MSSQLExample]
Description = Example server
Driver = FreeTDS
Trace = No
Server = 127.0.0.1\INSTANCE1
Database = MyDatabase
port = 1434
And if all else fails, try using osql to get some feedback on which part is not working.
# osql -S MSSQLExample -U USERNAME -P PASSWORD
And for some good info on tsql error messages: http://freetds.schemamania.org/userguide/confirminstall.htm
Won't you need the SQL Server hostname or IP address in the freetds.conf file --
[sqlServer]
host = 192.168.0.99
:
Related
I am trying to connect locally installed steampipe to my local postgresql database container which is running on port 5432. So that i can see the output of my sql queries will be stored on my personal postgresql database. I don't want to use steampipe's own database.
I have taken have taken the following steps:
I ran on my wsl ubuntu terminal:
export STEAMPIPE_WORKSPACE_DATABASE=postgresql://postgresUser:postgresPW#localhost:5432/postgresDB --> reference to https://steampipe.io/docs/reference/env-vars/steampipe_workspace_database
I checked the configurations inside steampipe.
Made the change inside ~/.steampipe/config/default.spc
options "database" {
port = 5432 # any valid, open port number
listen = "local" # local, network
#search_path = "" # comma-separated string
}
I added the line inside ~/.steampipe/db/14.2.0 /data/postgresql.conf
listen_addresses = '*'
I added the line inside ~/.steampipe/db/14.2.0/data/pg_hba.conf
host all all 0.0.0.0/0
Still i am unable to connect steampipe to my local postgresql database container which is running on port 5432
On executing: steampipe service start, I am getting below result
Error: cannot listen on port 5432
I want to connect to a remote SQL Server from WSL2, but I keep getting errors for some reason. I tried connecting using my Windows Host machine without any problem.
~/.odbc.ini
[MSSQLTest]
Description=Microsoft ODBC Driver 17 for SQL Server
Driver=/opt/microsoft/msodbcsql17/lib64/libmsodbcsql-17.9.so.1.1
server=tcp:server,port
Database=Databasename
Trusted_Connection=yes
TrustServerCertificate=yes
uid=username#domain.com
pwd=password
odbcinst -j
unixODBC 2.3.7
DRIVERS............: /etc/odbcinst.ini
SYSTEM DATA SOURCES: /etc/odbc.ini
FILE DATA SOURCES..: /etc/ODBCDataSources
USER DATA SOURCES..: /home/test/.odbc.ini
SQLULEN Size.......: 8
SQLLEN Size........: 8
SQLSETPOSIROW Size.: 8
Errors
test#Desktop:/mnt/c/Users/test$ isql -v mssqltest
[S1000][unixODBC][Microsoft][ODBC Driver 17 for SQL Server]SSPI Provider: No Kerberos credentials available (default cache: FILE:/tmp/krb5cc_1000)
[S1000][unixODBC][Microsoft][ODBC Driver 17 for SQL Server]Cannot generate SSPI context
I tried several different changes in the DSN, but none worked. The only thing that changed was the error messages. Then I tried installing mssql-tools to use sqlcmd, but I got similar errors.
Errors
test#DESKTOP:/mnt/c/Users/test$ sqlcmd -S server -U domain\\username -P password -G
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : SSL Provider: [error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed:self signed certificate].
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Client unable to establish the connection.
I have no idea what the error above means.
test#DESKTOP:/mnt/c/Users/test$ sqlcmd -S server#example.com -U domain\username -P password -G
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : SSL Provider: [error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed:self signed certificate].
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Client unable to establish connection.
I get a similar error. If I change something in the DSN, I get an error stating No kerberos credentials available (default cache: FIEL:/tmp/krb5cc_1000). Cannot generate SSPI context.
I looked up and tried many different solutions suggested on SO and other sites, but I can't seem to get it working. I can, however, ping the server.
Why is it doing this? Why does my connection work from my Windows Host machine but not WSL? What am I missing?
I don't think there's anything wrong with your setup. You might want to check if your admin allows SQL Authentication. Then use the sqlcmd to check if it works for you. You may be able to figure out the solution then.
sqlcmd -SXX.XX.XX.XXX -U username -P password -Q "select top 5 * from your_table"
I am connected to remote Oracle server from my local machine & dropped all the table in one of the db schema. Now I need to import a dmp file located in the same remote machine from my machine. How can I achieve that?
Note - RDC to the server its not an option.
I can't use impdp as that utility is not available in my local machine.
Please help
I achieved this by SSH. I configured a SSH server on the Oracle DB machine then from my local machine ran impdp command via ssh using paramiko client.
......................................................................................
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(server, username=username, password=password)
ssh_stdin, ssh_stdout, ssh_stderr = ssh.exec_command('<impdp command here>')
err = ssh_stderr.read()
print "err", err, len(err)
ssh.close()
I'm trying to connect to SQL-Azure from Ubuntu 12.04.
I've compiled freeTds-0.91 with openssl and libiconf
tsql -H XXXXXXXX.database.windows.net -U Username -D DatabaseName -p 1433 -P Password
I try connect using the above statement and I get this error:
locale is "en_ZA.UTF-8"
locale charset is "UTF-8"
using default charset "UTF-8"
Default database being set to DatabaseName
Error 20004 (severity 9):
Read from the server failed
OS error 104, "Connection reset by peer"
Error 20002 (severity 9):
Adaptive Server connection failed
There was a problem connecting to the server
My tsql -C output:
Compile-time settings (established with the "configure" script)
Version: freetds v0.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: 5.0
iODBC: no
unixodbc: no
SSPI "trusted" logins: no
Kerberos: no
I can't seem to find any information on what is causing and how to resolve this issue.
Any help will be much appreaciated.
The error is caused by the use of the wrong version of TDS.
To resolve just specify the TDS version before the tsql command:
TDSVER=8.0 tsql -H XXXXXXXX.database.windows.net -U Username -D DatabaseName -p 1433 -P Password
Is your IP address whitelisted by the database server? If not, you won't be able to connect.
in freetds.conf
[servername]
host = ipAddress
port = 1433
tds version = 8.0
for checking freetds connection
===============================
$tsql -S servername -U username
password
Do with TDS 8.0 version worked for me.
Just put in /etc/freetds/freetds.conf to stay permanent
I am running as my Host OS - Win 7 x64 and running an instance of SQL Server 2005 (developer, x64). I am also running an instance of Virtual PC XP and am trying to connect to the Host OS Sql Instance without alot of luck.
I can ping the Host from the Guest OS and vice versa.
The Virtual PC Guest is not using the NAT network adapter, but the physical adapter of the machine.
I ran SQL Server Surface Area Configuration tool on the host and made sure both local and remote connections are allowed for both TCP/IP and Named pipes.
I installed the SQL Server 2005 Native client on the Guest XP OS as well as SQLCMD.
When I issue: "SQLCMD -L" I see:
Servers:
ROBSWIN7BOX
However when I try "SQLCMD -S ROBSWIN7BOX", I get:
HResult 0x52E, Level 16, State 1
Named Pipes Provider: Could not open a connection to SQL Server [1326].
Sqlcmd: Error: Microsoft SQL Native Client : An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connection
s..
Sqlcmd: Error: Microsoft SQL Native Client : Login timeout expired.
I've also tried various SQLCMD -S .. -U sa .. -P and SQLCMD -S ... -E (SQL Server is configured for Mixed mode authentication).
Any ideas? What am I overlooking?
THanks!
Rob
Error 0x52e: (Win32) 0x52e (1326) - Logon failure: unknown user name or bad password.
You need Win auth to open the named pipe. Make sure SQL port is open by firewall on host and force tcp in your connection: SQLCDM -S tcp:ROBSWIN7BOX -U user -P pwd