Skip to content

Centos7安装sqlserver2017

一、安装

#创建目录
mkdir -p /opt/sqlserver2017
cd /opt/sqlserver2017/ 

#下载
wget --no-check-certificate https://packages.microsoft.com/rhel/7/mssql-server-2017/mssql-server-14.0.1000.169-2.x86_64.rpm

#安装依赖
yum install bzip2 gdb libsss_nss_idmap

#安装
rpm -ivh mssql-server-14.0.1000.169-2.x86_64.rpm
#创建目录
mkdir -p /opt/sqlserver2017
cd /opt/sqlserver2017/ 

#下载
wget --no-check-certificate https://packages.microsoft.com/rhel/7/mssql-server-2017/mssql-server-14.0.1000.169-2.x86_64.rpm

#安装依赖
yum install bzip2 gdb libsss_nss_idmap

#安装
rpm -ivh mssql-server-14.0.1000.169-2.x86_64.rpm
  • 效果图

效果图

1.1 配置

[root@iZwz94664y88ud9aroa5veZ sqlserver2017]# /opt/mssql/bin/mssql-conf setup
Choose an edition of SQL Server:
  1) Evaluation (free, no production use rights, 180-day limit)
  2) Developer (free, no production use rights)
  3) Express (free)
  4) Web (PAID)
  5) Standard (PAID)
  6) Enterprise (PAID)
  7) Enterprise Core (PAID)
  8) I bought a license through a retail sales channel and have a product key to enter.
 
Details about editions can be found at
https://go.microsoft.com/fwlink/?LinkId=852748&clcid=0x409
 
Use of PAID editions of this software requires separate licensing through a
Microsoft Volume Licensing program.
By choosing a PAID edition, you are verifying that you have the appropriate
number of licenses in place to install and run this software.
 
Enter your edition(1-8): 2
The license terms for this product can be found in
/usr/share/doc/mssql-server or downloaded from:
https://go.microsoft.com/fwlink/?LinkId=855862&clcid=0x409
 
The privacy statement can be viewed at:
https://go.microsoft.com/fwlink/?LinkId=853010&clcid=0x409
 
Do you accept the license terms? [Yes/No]:Yes
 
Enter the SQL Server system administrator password: 
Confirm the SQL Server system administrator password: 
Configuring SQL Server...
 
Created symlink from /etc/systemd/system/multi-user.target.wants/mssql-server.service to /usr/lib/systemd/system/mssql-server.service.
Setup has completed successfully. SQL Server is now starting.
[root@iZwz94664y88ud9aroa5veZ sqlserver2017]#
[root@iZwz94664y88ud9aroa5veZ sqlserver2017]# /opt/mssql/bin/mssql-conf setup
Choose an edition of SQL Server:
  1) Evaluation (free, no production use rights, 180-day limit)
  2) Developer (free, no production use rights)
  3) Express (free)
  4) Web (PAID)
  5) Standard (PAID)
  6) Enterprise (PAID)
  7) Enterprise Core (PAID)
  8) I bought a license through a retail sales channel and have a product key to enter.
 
Details about editions can be found at
https://go.microsoft.com/fwlink/?LinkId=852748&clcid=0x409
 
Use of PAID editions of this software requires separate licensing through a
Microsoft Volume Licensing program.
By choosing a PAID edition, you are verifying that you have the appropriate
number of licenses in place to install and run this software.
 
Enter your edition(1-8): 2
The license terms for this product can be found in
/usr/share/doc/mssql-server or downloaded from:
https://go.microsoft.com/fwlink/?LinkId=855862&clcid=0x409
 
The privacy statement can be viewed at:
https://go.microsoft.com/fwlink/?LinkId=853010&clcid=0x409
 
Do you accept the license terms? [Yes/No]:Yes
 
Enter the SQL Server system administrator password: 
Confirm the SQL Server system administrator password: 
Configuring SQL Server...
 
Created symlink from /etc/systemd/system/multi-user.target.wants/mssql-server.service to /usr/lib/systemd/system/mssql-server.service.
Setup has completed successfully. SQL Server is now starting.
[root@iZwz94664y88ud9aroa5veZ sqlserver2017]#
  • 验证
systemctl status mssql-server
systemctl status mssql-server

1.2 服务

  • 停止、启动或重启 SQL Server 服务
systemctl stop mssql-server
systemctl start mssql-server
systemctl restart mssql-server
systemctl stop mssql-server
systemctl start mssql-server
systemctl restart mssql-server

1.3 日志

/var/opt/mssql/log/errorlog

1.4 安装 sqlcmd 和 bcp SQL Server 命令行工具

wget --no-check-certificate https://packages.microsoft.com/rhel/7.3/prod/msodbcsql-13.1.6.0-1.x86_64.rpm

wget --no-check-certificate https://packages.microsoft.com/rhel/7.3/prod/mssql-tools-14.0.5.0-1.x86_64.rpm
wget --no-check-certificate https://packages.microsoft.com/rhel/7.3/prod/msodbcsql-13.1.6.0-1.x86_64.rpm

wget --no-check-certificate https://packages.microsoft.com/rhel/7.3/prod/mssql-tools-14.0.5.0-1.x86_64.rpm
  • 安装
yum localinstall msodbcsql-13.1.6.0-1.x86_64.rpm
yum localinstall mssql-tools-14.0.5.0-1.x86_64.rpm
yum localinstall msodbcsql-13.1.6.0-1.x86_64.rpm
yum localinstall mssql-tools-14.0.5.0-1.x86_64.rpm
  • 设置环境变量
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile
source ~/.bash_profile 
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
source ~/.bashrc
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile
source ~/.bash_profile 
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
source ~/.bashrc
  • 测试数据库连接
sqlcmd -S localhost -U sa

#输入密码
sqlcmd -S localhost -U sa

#输入密码

passwd