关闭SELINUX
sed -i '/^SELINUX/s/enforcing/disabled/g' /etc/selinux/config && setenforce 0
添加软件源并安装依赖包
# sql server 2019 软件源,其他版本软件源:https://packages.microsoft.com/config/rhel/
curl https://packages.microsoft.com/config/rhel/8/mssql-server-2019.repo -o /etc/yum.repos.d/msprod.repo
curl https://packages.microsoft.com/config/rhel/8/prod.repo -o /etc/yum.repos.d/msprod.repo
# rpm -Uvh https://packages.microsoft.com/config/rhel/7/packages-microsoft-prod.rpm
# rpm -Uvh https://packages.microsoft.com/config/rhel/8/packages-microsoft-prod.rpm
yum -y install mssql-tools unixODBC-devel bzip2 gdb libsss_nss_idmap cyrus-sasl cyrus-sasl-gssapi
安装SQL Server2019
yum install -y mssql-server
# 安装过程中根据提示输入两次yes
运行初始化配制
# /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) - 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 /etc/systemd/system/multi-user.target.wants/mssql-server.service → /usr/lib/systemd/system/mssql-server.service.
Setup has completed successfully. SQL Server is now starting.
添加环境变量
echo 'export PATH=$PATH:/opt/mssql-tools/bin' > /etc/profile.d/mssql.sh
[root@manager opt]# source !$
source /etc/profile.d/mssql.sh
防火墙添加服务
firewall-cmd --permanent --add-service=mssql
firewall-cmd --reload
命令行工具连接测试
# 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-CU18) (KB5017593) - 15.0.4261.1 (X64)
Sep 12 2022 15:07:06
Copyright (C) 2019 Microsoft Corporation
Express Edition (64-bit) on Linux (Rocky Linux 8.6 (Green Obsidian)) <X64>
(1 rows affected)
1>
Windows SSMS客户端下载安装
SQL Server Management Studio 18.12.1下载地址
评论区