本文参考了 https://learn.microsoft.com/zh-cn/sql/linux/install-upgrade/quickstart-install-ubuntu
适用于:SQL Server 2025 (17.x) CU 1 及更高版本。
步骤:
下载公钥,将其从 ASCII 转换为 GPG 格式,并将其写入所需位置:
curl -fsSL https://packages.microsoft.com/keys/microsoft.asc | sudo gpg --dearmor -o /usr/share/keyrings/microsoft-prod.gpg
手动下载并注册 SQL Server Ubuntu 存储库:
curl -fsSL https://packages.microsoft.com/config/ubuntu/24.04/mssql-server-2025.list | sudo tee /etc/apt/sources.list.d/mssql-server-2025.list
安装 SQL Server:
sudo apt-get update
sudo apt-get install -y mssql-server
包安装完成后,运行 mssql-conf setup,按照提示设置 sa 密码并选择版本。 以下 SQL Server 版本获自由许可:评估版、开发人员版和 Express 版。
sudo /opt/mssql/bin/mssql-conf setup
一开始会显示出版本列表:
Choose an edition of SQL Server:
1) Evaluation (free, no production use rights, 180-day limit)
2) Enterprise Developer (free, no production use rights)
3) Standard Developer (free, no production use rights)
4) Express (free)
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.
9) Standard (Billed through Azure) - Use pay-as-you-go billing through Azure.
10) Enterprise Core (Billed through Azure) - Use pay-as-you-go billing through Azure.
Details about editions can be found at
https://go.microsoft.com/fwlink/?LinkId=2109348
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.
By choosing an edition billed Pay-As-You-Go through Azure, you are verifying
that the server and SQL Server will be connected to Azure by installing the
management agent and Azure extension for SQL Server.
Enter your edition(1-10):
一般我们开发选 3 即可。
然后会询问是否接收许可条款:
The license terms for this product can be found in
/usr/share/doc/mssql-server or downloaded from: https://aka.ms/useterms
The privacy statement can be viewed at:
https://go.microsoft.com/fwlink/?LinkId=853010
Do you accept the license terms? [Yes/No]:
回答 y 即可。
然后会要求输入管理员密码:
Enter the SQL Server system administrator password:
Confirm the SQL Server system administrator password:
密码要求混合多种字符,不允许简单密码。
配置完成后,验证服务是否正在运行:
systemctl status mssql-server --no-pager
如果计划远程连接,可能还需要在防火墙上打开 SQL Server TCP 端口(默认值为 1433)。
此时,SQL Server 已在 Ubuntu 计算机上运行,随时可以使用。