LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   hi i want to connect mssql from my linux system . (https://www.linuxquestions.org/questions/linux-newbie-8/hi-i-want-to-connect-mssql-from-my-linux-system-4175546471/)

NAMACHEVAYAM 06-26-2015 01:33 AM

hi i want to connect mssql from my linux system .
 
hi guys i using redhat linux 6 system which has folling configuration settings

odbcinst -j
unixODBC 2.3.0
DRIVERS............: /usr/local/etc/odbcinst.ini
SYSTEM DATA SOURCES: /usr/local/etc/odbc.ini
FILE DATA SOURCES..: /usr/local/etc/ODBCDataSources
USER DATA SOURCES..: /root/.odbc.ini
SQLULEN Size.......: 8
SQLLEN Size........: 8
SQLSETPOSIROW Size.: 8

odbcinst -q -d -n "SQL Server Native Client 11.0"
[SQL Server Native Client 11.0]
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


in odbc.ini file contains
[MSSQLTest]
Driver=SQL Server Native Client 11.0
Description=My Sample ODBC Database Connection
Trace=Yes
Server=192.***.***.***
Port=1443
Database={name of database}

in odbcinst.ini file contains
[SQL Server Native Client 11.0]
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




but when i connect to sql means th below problem arrives

[root@Freedom Desktop]# isql

**********************************************
* unixODBC - isql *
**********************************************
* Syntax *
* *
* isql DSN [UID [PWD]] [options] *
* *
* Options *
* *
* -b batch.(no prompting etc) *
* -dx delimit columns with x *
* -x0xXX delimit columns with XX, where *
* x is in hex, ie 0x09 is tab *
* -w wrap results in an HTML table *
* -c column names on first row. *
* (only used when -d) *
* -mn limit column display width to n *
* -v verbose. *
* -lx set locale to x *
* -q wrap char fields in dquotes *
* -3 Use ODBC 3 calls *
* -n Use new line processing *
* -e Use SQLExecDirect not Prepare *
* --version version *
* *
* Commands *
* *
* help - list tables *
* help table - list columns in table *
* help help - list all help options *
* *
* Examples *
* *
* isql WebDB MyID MyPWD -w < My.sql *
* *
* Each line in My.sql must contain *
* exactly 1 SQL command except for the *
* last line which must be blank (unless *
* -n option specified). *
* *
* Please visit; *
* *
* http://www.unixodbc.org *
* pharvey@codebydesign.com *
* nick@easysoft.com *
**********************************************

[root@Freedom Desktop]# isql -v MSSQLTest username pwd
[S1T00][unixODBC][Microsoft][ODBC Driver 11 for SQL Server]Login timeout expired
[08001][unixODBC][Microsoft][ODBC Driver 11 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.
[08001][unixODBC][Microsoft][ODBC Driver 11 for SQL Server]TCP Provider: Error code 0x2AF9
[ISQL]ERROR: Could not SQLConnect
[root@Freedom Desktop]#






pls guys hep me to solve this problem pls pls,, i really needs urgently the solution

MensaWater 06-26-2015 08:32 AM

Your error mentions "mysql". That is NOT the same thing as "mssql". MySQL is an opensource datatabase. MSSQL is a proprietary database on MS Windows (originally derived from Sybase).

I haven't tried to connect to MSSQL on Windows from Linux but doing a search yields several hits the first of which looks like it might be useful:
http://richbs.org/post/43142767072/c...rver-from-unix

That suggests use of FreeTDS for talking to MSSQL. The link they have in the above post for FreeTDS isn't working but I found their main site is still active:
http://www.freetds.org/

Be careful in your searches - the next link after the one I mention above was talking about unixODBC but clearly for mysql rather than mssql.

Habitual 06-26-2015 09:30 AM

Here is a sample from a working host:
Code:

cat /usr/local/etc/odbcinst.ini
[SQL Server Native Client 11.0]
Description=Microsoft SQL Server ODBC Driver V1.0 for Linux
Driver=/opt/microsoft/sqlncli/lib64/libsqlncli-11.0.so.1790.0
Threading=1
UsageCount=2

[FreeTDS]
Description=TDS driver (Sybase/MS SQL)
Driver=/usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so
UsageCount=1

cat /usr/local/etc/odbc.ini
[oscardsn]
Driver = FreeTDS
Description = MSSQL database for my nice app
# Servername corresponds to the section in freetds.conf
Servername=DressingRoom_Server
Database = DressingRoom

and we connect using
Code:

isql -v <dsn> <user> <pass>
and worked that out from the same link MensaWater provided.


All times are GMT -5. The time now is 05:49 PM.