关闭SELINUX
[root@localhost ~]# sed -i '/^SELINUX/s/enforcing/disabled/g' /etc/selinux/config && setenforce 0
上传rpm包和依赖包 下载地址 https://pkgs.org/
依赖包(按顺序安装):
bzip2-1.0.6-13.el7.x86_64.rpm
cyrus-sasl-2.1.26-23.el7.x86_64.rpm
cyrus-sasl-gssapi-2.1.26-23.el7.x86_64.rpm
gdb-7.6.1-120.el7.x86_64.rpm
libsss_nss_idmap-1.16.5-10.el7.x86_64.rpm
libtool-ltdl-2.4.2-22.el7_3.x86_64.rpm
unixODBC-2.3.1-14.el7.x86_64.rpm
unixODBC-devel-2.3.1-14.el7.x86_64.rpm
msodbcsql17-17.8.1.1-1.x86_64.rpm
mssql-tools-17.8.1.1-1.x86_64.rpm
依赖包安装完成再安装 sql server 2019
sqlserver2019:
mssql-server-15.0.4003.23-3.x86_64.rpm
[root@localhost 依赖包]# rpm -ivh bzip2-1.0.6-13.el7.x86_64.rpm gdb-7.6.1-120.el7.x86_64.rpm cyrus-sasl-2.1.26-23.el7.x86_64.rpm cyrus-sasl-gssapi-2.1.26-23.el7.x86_64.rpm libsss_nss_idmap-1.16.5-10.el7.x86_64.rpm libtool-ltdl-2.4.2-22.el7_3.x86_64.rpm unixODBC-2.3.1-14.el7.x86_64.rpm unixODBC-devel-2.3.1-14.el7.x86_64.rpm msodbcsql17-17.8.1.1-1.x86_64.rpm mssql-tools-17.8.1.1-1.x86_64.rpm
[root@localhost sql server2019]# rpm -ivh mssql-server-15.0.4003.23-3.x86_64.rpm
运行初始化配制
[root@localhost ~]# /opt/mssql/bin/mssql-conf setup
usermod: no changes
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) - CPU Core utilization restricted to 20 physical/40 hyperthreaded
7) Enterprise Core (PAID) - CPU Core utilization up to Operating System Maximum
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=2109348&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): 3 #这里选择了Express版本
The license terms for this product can be found in
/usr/share/doc/mssql-server or downloaded from:
https://go.microsoft.com/fwlink/?LinkId=2104294&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 #输入Yes接受许可条目
Enter the SQL Server system administrator password: #设置SA管理员密码
Confirm the SQL Server system administrator password:
Configuring SQL Server...
The licensing PID was successfully processed. The new edition is [Express Edition].
ForceFlush is enabled for this instance.
ForceFlush feature is enabled for log durability.
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@localhost ~]# echo 'export PATH=$PATH:/opt/mssql-tools/bin' > /etc/profile.d/mssql.sh
[root@localhost ~]# source !$
source /etc/profile.d/mssql.sh
防火墙添加服务
[root@localhost ~]# firewall-cmd --permanent --add-service=mssql
success
[root@localhost ~]# firewall-cmd --reload
success
命令行工具连接测试
[root@localhost ~]# sqlcmd -S localhost -U sa
Password:
# 显示系统数据库
1> select name,database_id from sys.databases;
# 执行
2> go
name database_id
-------------------------------------------------------------------------------------------------------------------------------- -----------
master 1
tempdb 2
model 3
msdb 4
(4 rows affected)
# 查看软件版本
1> SELECT @@VERSION
2> go
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Microsoft SQL Server 2019 (RTM-CU1) (KB4527376) - 15.0.4003.23 (X64)
Dec 6 2019 14:53:33
Copyright (C) 2019 Microsoft Corporation
Express Edition (64-bit) on Linux (CentOS Linux 7 (Core))
(1 rows affected)
1>
查看IP 192.168.10.20
[root@localhost ~]# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:0f:ba:9e brd ff:ff:ff:ff:ff:ff
inet 192.168.10.20/24 brd 192.168.10.255 scope global noprefixroute dynamic ens33
valid_lft 84901sec preferred_lft 84901sec
inet6 fe80::b455:3506:530f:d83c/64 scope link noprefixroute
valid_lft forever preferred_lft forever
参考地址:https://www.linuxprobe.com/centos7-instal-mssql-2019.html