20130607 setup odbc on rhel for ms sql - plembo/onemoretech GitHub Wiki

title: Setup ODBC on RHEL for MS SQL link: https://onemoretech.wordpress.com/2013/06/07/setup-odbc-on-rhel-for-ms-sql/ author: phil2nc description: post_id: 6026 created: 2013/06/07 10:51:00 created_gmt: 2013/06/07 14:51:00 comment_status: closed post_name: setup-odbc-on-rhel-for-ms-sql status: publish post_type: post

Setup ODBC on RHEL for MS SQL

Most enterprise sysadmins can't afford to ignore the presence of Microsoft's SQL Server in the data center. Steps to set up ODBC on RHEL for MS SQL follow. These instructions were tested successfully on RHEL 6. Taken from Perl to Microsoft SQL Server 2008 Standard via ODBC using FreeTDS by Lance Vermilion. The following packages need to be installed: unixODBC unixODBC-devel freetds In addition you may need the following: php-odbc For those who may need to work with perl scripts, the recommended route is to install: DBD::ODBC (perl's DBI package should already be installed) Once the above prerequists above are installed, DBD::ODBC can be installed with:

perl -MCPAN -e "install 'DBD::ODBC'"

The following steps should be followed in order to install and configure ODBC for communicating with MS SQL: 1. Check to see what ODBC drivers are already installed:

odbcinst -q -d

2. Check the location of the ODBC configuration files:

odbcinst -j

In RHEL and Fedora this should be: /etc/odbcinst.ini (driver definitions) /etc/odbc.ini (connection objects) 2. Assuming the FreeTDS driver is not installed, here is how to set it up: a. Create a TDS driver tempate for ODBC: /var/tmp/tds.driver.template

[FreeTDS]
Driver = /usr/lib64/libtdsodbc.so.0

b. Install the driver from this template:

odbcinst -i -d -f /var/tmp/tds.driver.template

c. Configure a connection object: /etc/odbc.ini

[TESTDB]
Driver = FreeTDS
Address = somedbserver.adsdomain.example.com
Port = 1433
Database = TESTDB

d. Test the connection:

[me@mine]$ isql -v -s TESTDB testuser testpass
+---------------------------------------+
| Connected!                            |
|                                       |
| sql-statement                         |
| help [tablename]                      |
| quit                                  |
|                                       |
+---------------------------------------+
SQL> 

Note: Use this command to list all available DSNs:

odbcinst -q -s

Copyright 2004-2019 Phil Lembo