Linux connect MSSQL installation
#find and install
install php5-odbc freetds-tools libfreetds libtdsodbc0 unixODBC unixODBC-32bit unixODBC_23
#test tds is work
a) ping to see if you are connected to Windows PC
# ping 192.168.1.33
b) telnet to see if port 1433 is open on Windows PC for MS SQL connection
# telnet 192.168.1.33 1433
Trying 192.168.1.33…
Connected to 192.168.1.33.
Escape character is ‘^]’.
c) tsql to see if freeTDS works
# tsql -H 192.168.1.33 -p 1433 -U my_mssql_username
locale is “en_US.UTF-8″
locale charset is “UTF-8″
Password: my_mssql_password
1>
d) tsql to see if freeTDS automatic configuration from /ets/freetds.conf works
edit /etc/freetds.conf
and change last section to this:
—————————
Code:
# A typical Microsoft server
[MSSQL_VBOX]
#host = ntmachine.domain.com
#port = 1433
host = 192.168.1.33
port = 1040
tds version = 8.2
client charset = UTF-8
—————————
# tsql -S MSSQL_VBOX -U my_mssql_username
locale is “en_US.UTF-8″
locale charset is “UTF-8″
Password: my_mssql_password
1>
#check odbc config file
odbcinst -j
#server setting path
/etc/odbc.ini
# Define a connection to a Microsoft SQL server
# The Description can be whatever we want it to be.
# The Driver value must match what we have defined in /etc/odbcinst.ini
# The Database name must be the name of the database this connection will connect to.
# The ServerName is the name we defined in /etc/freetds/freetds.conf
# The TDS_Version should match what we defined in /etc/freetds/freetds.conf
[mssql]
Description = MSSQL Server
Driver = freetds
Database = XXXXXX
Server = xxx.xxx.xxx.xxx
TDS_Version = 7.0
#driver path
/etc/odbcinst.ini
# Define where to find the driver for the Free TDS connections.
[freetds]
Description = MS SQL database access with Free TDS
Driver = /usr/lib/i386-linux-gnu/odbc/libtdsodbc.so
Setup = /usr/lib/i386-linux-gnu/odbc/libtdsS.so
UsageCount = 1
#sample php connect mssql
#pdo
$connection = new PDO(‘odbc:Driver=FreeTDS;server=192.168.1.33;database=dbName;port=1433;’, “sa", “");.
#odbc
$connection = odbc_connect(“Driver=FreeTDS;Server=192.168.1.33;Database=dbName;port=1433;", “sa", “");