Setup Linux ODBC database connections into Microsoft SQL  

Setup Linux ODBC database connections into Microsoft SQL:

In this example I am using CentOS6_64x to connect to my Microsoft SQL database server

yum install php php-odbc wget gcc php-pear php-pecl-apc php-xml php-xmlrpc php-intl php-tidy php-imap php-pecl-memcache

 

Grab the client from Microsoft

wget http://download.microsoft.com/download/6/A/B/6AB27E13-46AE-4CE9-AFFD-406367CADC1D/Linux6/sqlncli-11.0.1790.0.tar.gz

tar xvf sqlncli-11.0.1790.0.tar.gz

cd sqlncli-11.0.1790.0
 ./build_dm.sh

 

After that:

cd /tmp/unixODBC.5996.21582.3453/unixODBC-2.3.0

make install

cd /path_do_sql_client_download/sqlncli-11.0.1790.0

./install.sh install --lib-dir=/usr/local/lib64 --accept-license

 

Now I have to installed the Microsoft ODBC Client I edit the /etc/odbc.ini file and setup proper DSNName values

 

nano /etc/odbc.ini

[MyDSNName]
 Driver=ODBC Driver 13 for SQL Server
 Description=Database
 Trace=Yes
 Server=172.17.17.234
 Port=1433
 Database=database1
 MSSqlUser=sa
 MSSqlUserPassword=PASSWORDHERE
 MARS_Connection=yes

Test

isql -v MyDSNName MSSqlUser MSSqlUserPassword

I also had to restart apache for the new modules to be loaded for database access via my web page

service httpd restart

Leave a Reply

Your email address will not be published. Required fields are marked *