在 CentOS 上安装 SQL Server,您可以选择安装 SQL Server 的 Linux 版本,即 SQL Server on Linux
sudo yum update -y
sudo yum install -y wget openssl11-devel libaio libcurl libxml2-devel bzip2-devel libjpeg-turbo-devel freetype-devel libpng-devel
wget https://packages.microsoft.com/config/rhel/7/prod.list
sudo bash -c 'cat <<EOF > /etc/yum.repos.d/mssql-release.repo
[mssql-release]
name=Microsoft SQL Server
baseurl=https://packages.microsoft.com/yum/rhel/7/prod
enabled=1
gpgcheck=1
gpgkey=https://packages.microsoft.com/keys/microsoft.asc
EOF'
sudo yum install -y msodbcsql17
sudo yum install -y unixodbc-devel
sudo curl https://packages.microsoft.com/keys/microsoft.asc | sudo tee -a /etc/pki/rpm-gpg/RPM-GPG-KEY-microsoft
sudo yum install -y msodbcsql17-tools
echo 'export PATH=/opt/mssql/bin:$PATH' >> ~/.bashrc
source ~/.bashrc
sudo systemctl start mssql-server
sudo systemctl enable mssql-server
sqlcmd -S localhost -U sa -P YourPassword
输入上述命令后,如果成功连接到 SQL Server,您将看到类似以下的输出:
1> SELECT @@VERSION;
2> GO
SELECT @@VERSION;
-----------------------------
Microsoft SQL Server 2019 (RTM) - 15.0.2000.51
-----------------------------
现在您已经在 CentOS 上成功安装了 SQL Server。