centos7安装sqlserver数据库,并且安装python2.7版本pymssql模块进行sqlserver连接

centos7.x安装sqlserver2017免费版

步骤:

curl -o /etc/yum.repos.d/mssql-server.repo https://packages.microsoft.com/config/rhel/7/mssql-server-2017.repo
ll /etc/yum.repos.d/mssql-server.repo
yum update -y
yum install -y mssql-server
cd /opt/mssql/bin
./mssql-conf setup
ps -ef |grep sql
systemctl start mssql-server
#开启外部连接端口
firewall-cmd --add-port='1433/tcp' --permanent
firewall-cmd –reload

======================================================================

 

安装完毕,上面建立过程中会输入库的密码,初始库的用户名是sa

安装完后的sqlservver,select @@VERSION输出如下:
版本号:
    Microsoft SQL Server 2017 (RTM-CU17) (KB4515579) - 14.0.3238.1 (X64) 
    Sep 13 2019 15:49:57 
    Copyright (C) 2017 Microsoft Corporation
    Developer Edition (64-bit) on Linux (CentOS Linux 7 (Core))

======================================================================
linux下python2.7安装pymssql模块

安装步骤:

1. 安装freetds
tar -zxvf freetds-0.82.tar.gz
cd freetds-0.82
./configure --prefix=/usr/local/freetds --with-tdsver=8.0 --enable-msdblib --enable-dbmfix --with-gnu-ld --enable-shared --enable-static
make&&make install
echo "/usr/local/freetds/lib" >> /etc/ld.so.conf.d/freetds.conf
ldconfig -v

2. 安装setuptools
unzip setuptools-41.6.0.zip
cd setuptools-41.6.0
python setup.py install


3. 安装pymssql
tar zxvf pymssql-2.1.0.tar.gz
cd pymssql-2.1.0
python setup.py install
注:如果不安装freetds,会报如下错误:
error: command 'gcc' failed with exit status 1

资源网站地址:
freetds的官网0.82版本
https://www.freetds.org/software.html
psmssql2.1.0版本
https://pypi.org/search/?q=pymssql2.1.0&o=
setuptools/setuptools-41.6.0
https://pypi.org/project/setuptools/

freetds的官网0.82版本、psmssql2.1.0版本、setuptools/setuptools-41.6.0安装包见我的资源库

 

你可能感兴趣的:(DB,python)