官方文档
1.下载 Microsoft SQL Server 2019 Red Hat 存储库配置文件
sudo curl -o /etc/yum.repos.d/mssql-server.repo https://packages.microsoft.com/config/rhel/8/mssql-server-2019.repo
2.安装 SQL Server
sudo yum install -y mssql-server
3.运行 mssql-conf setup,按照提示选择版本并设置 SA 密码
sudo /opt/mssql/bin/mssql-conf setup
选择版本2
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.
重复输入两次相同的强策略密码 Enter the SQL Server system administrator password: Confirm the SQL Server system administrator password:
输入完毕后如果服务器内初小于2000M,则会报错
Configuring SQL Server... sqlservr: This program requires a machine with at least 2000 megabytes of memory. /opt/mssql/bin/sqlservr: This program requires a machine with at least 2000 megabytes of memory. Initial setup of Microsoft SQL Server failed. Please consult the ERRORLOG in /var/opt/mssql/log for more information.
解决方法-使用python2进行修改
要用python2,python3不行
python2 安装
dnf install python2
切换工作目录:
1 |
|
备份原文件
1 |
|
重命名原文件
1 |
|
使用python进行修改
1 |
|
1 2 3 4 |
|
修改完后,设置权限
1 |
|
修改完成后再重新运行 mssql-conf setup,按照提示选择版本并设置 SA 密码
sudo /opt/mssql/bin/mssql-conf setup
配置完成后,查看服务是否启动成功
systemctl status mssql-server
安装 SQL Server 命令行工具
若要创建数据库,则需要使用可在 SQL Server 上运行 Transact-SQL 语句的工具进行连接。
1.下载 Microsoft Red Hat 存储库配置文件
sudo curl -o /etc/yum.repos.d/msprod.repo https://packages.microsoft.com/config/rhel/8/prod.repo
2.如果安装了早期版本的 mssql-tools,请删除所有旧的 unixODBC 包
sudo yum remove unixODBC-utf16 unixODBC-utf16-devel
3.运行以下命令,以使用 unixODBC 开发人员包安装 mssql-tools。
sudo yum install -y mssql-tools unixODBC-devel
安装时,会出现以下提醒,输入YES即可继续
The license terms for this product can be downloaded from https://aka.ms/odbc17eula and found in /usr/share/doc/msodbcsql17/LICENSE.txt . By entering 'YES', you indicate that you accept the license terms. Do you accept the license terms? (Enter YES or NO)
4.向 PATH 环境变量添加 /opt/mssql-tools/bin/
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc source ~/.bashrc
本地连接
sqlcmd -S localhost -U SA -P '<YourPassword>'
本地操作可在此处进行查看
其余配置可通过此文档进行查看