当前位置:   article > 正文

linux访问sqlserver配置(CentOS6.8访问sqlserver2005)_linux下sql server怎么查看配置

linux下sql server怎么查看配置

1、安装Linux系统的ODBC

wget http://mirrors.163.com/centos/6/os/x86_64/Packages/unixODBC-2.2.14-14.el6.x86_64
wget http://mirrors.163.com/centos/6/os/x86_64/Packages/unixODBC-devel-2.2.14-14.el6.x86_64
wget http://mirrors.163.com/centos/6/os/x86_64/Packages/unixODBC-kde-2.2.14-14.el6.x86_64

rpm -ivh unixODBC-2.2.14-14.el6.x86_64
rpm -ivh unixODBC-devel-2.2.14-14.el6.x86_64
rpm -ivh unixODBC-kde-2.2.14-14.el6.x86_64
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

2、FreeTDS的安装与配置

下载:freetds-stable.tgz

http://ibiblio.org/pub/Linux/ALPHA/freetds/stable/freetds-stable.tgz
tar -zxvf freetds-stable.tgz
cd freetds-0.91/
./configure --prefix=/usr/local/freetds --with-tdsver=7.1  --enable-msdblib --with-gnu-ld --enable-shared --enable-static
make
make install
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

3、配置 unixODBC 和 FreeTDS

3.1配置freetds的数据源
vi /usr/local/freetds/etc/freetds.conf
  • 1
[mssql]
host = 192.168.100.9
port = 1433
tds version = 7.0
  • 1
  • 2
  • 3
  • 4

测试数据源

/usr/local/freetds/bin/tsql -S mssql -U sa -P password -D database
  • 1

提示如下,证明配置成功。

locale is "zh_CN.UTF-8"
locale charset is "UTF-8"
using default charset "UTF-8"
Default database being set to bodycheck
1> 
  • 1
  • 2
  • 3
  • 4
  • 5
3.2向unixODBC 登记 FreeTDS 驱动,指明odbc的驱动程序

vi /etc/odbcinst.ini

[SQLSERVER]
Description=freetds driver
Driver=/usr/local/freetds/lib/libtdsodbc.so
  • 1
  • 2
  • 3
3.3配置odbc.ini

vi /etc/odbc.ini

[sql]
Driver=MSSQLSERVER            #驱动名
Description=MSSQL Server
Servername=mssql              #数据源
Database=database
  • 1
  • 2
  • 3
  • 4
  • 5

配置完成,访问数据库
isql -v sql user password

+---------------------------------------+
| Connected!                            |
|                                       |
| sql-statement                         |
| help [tablename]                      |
| quit                                  |
|                                       |
+---------------------------------------+
SQL> 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Cpp五条/article/detail/452875
推荐阅读
相关标签
  

闽ICP备14008679号