centos7 安装sqlserver 2017和sqlcmd 工具

安装数据库

root用户

curl -o /etc/yum.repos.d/mssql-server.repo https://packages.microsoft.com/config/rhel/7/mssql-server-2017.repo
yum update
yum install -y mssql-server

初始化配置
/opt/mssql/bin/mssql-conf setup
选开发版
设置sa密码

关闭防火墙:
systemctl stop firewalld.service
关闭开机启动:
systemctl disable firewalld.service

安装sqlcmd工具

下载 Microsoft Red Hat 存储库配置文件
curl -o /etc/yum.repos.d/msprod.repo https://packages.microsoft.com/config/rhel/7/prod.repo

yum update
如果服务器以前安装过mssql,需要删除任何较旧的 unixODBC 程序包
yum remove unixODBC-utf16 unixODBC-utf16-devel

运行以下命令以安装mssql 工具与 unixODBC 开发人员包
yum update
yum install -y mssql-tools unixODBC-devel

添加/opt/mssql-tools/bin/路径到环境变量
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >>/etc/profile

连接数据库
sqlcmd -S localhost -U daifu -P settle

切换数据库
use pub
go

通过命令行执行查询
sqlcmd -S localhost -U daifu -P daifu -Q "truncate table pub.wx.tbl_daifu_urllog"

 

下载sqlserver management studio

https://docs.microsoft.com/zh-cn/sql/ssms/download-sql-server-management-studio-ssms

 

参考:

http://blog.csdn.net/cmzsteven/article/details/78161516 比较全面

https://docs.microsoft.com/zh-cn/sql/linux/quickstart-install-connect-red-hat

http://www.linuxidc.com/Linux/2017-12/149609.htm

 

 

© 2018, 新之助meow. 原创文章转载请注明: 转载自http://www.xinmeow.com

0.00 avg. rating (0% score) - 0 votes
点赞