Debian上SQL Server兼容性问题的解决方法
确保Debian系统满足SQL Server的最低运行条件:需使用SQL Server 2017及以上版本(官方仅支持该版本及以上的Linux适配);系统需具备至少2GB内存、6GB磁盘空间、2GHz处理器(x64架构);文件系统需为XFS或EXT4(SQL Server 2017不支持BTRFS等文件系统)。
安装前需更新系统并安装必要依赖:
sudo apt update && sudo apt upgrade -y
sudo apt install -y curl gnupg apt-transport-https
若安装过程中出现依赖缺失(如libldap-2.4-2
),可手动下载对应deb包并安装:
sudo dpkg -i libldap-common_2.4.47dfsg.4-1eagle_all.deb
sudo dpkg -i libldap-2.4-2_2.4.47dfsg.4-1eagle_amd64.deb
安装完成后运行sudo apt --fix-broken install
修复依赖关系。
通过官方存储库安装SQL Server,避免第三方源的兼容性问题:
curl https://packages.microsoft.com/keys/microsoft.asc | sudo gpg --dearmor -o /usr/share/keyrings/microsoft-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/microsoft-archive-keyring.gpg] https://packages.microsoft.com/debian/$(lsb_release -rs)/prod stable main" | sudo tee /etc/apt/sources.list.d/mssql-server.list
sudo apt update
注意:$(lsb_release -rs)
需替换为Debian的实际版本号(如Debian 12对应12
)。
运行配置脚本设置SA用户密码(需符合复杂度要求):
sudo /opt/mssql/bin/mssql-conf setup
启动SQL Server服务并设置开机自启:
sudo systemctl start mssql-server
sudo systemctl enable mssql-server
检查服务状态确认运行正常:
sudo systemctl status mssql-server
```。
### **5. 远程连接配置**
若需远程访问,需开放防火墙的**TCP 1433端口**(默认SQL Server端口):
```bash
sudo ufw allow 1433/tcp
确保SQL Server配置允许远程连接(可通过sqlcmd
工具登录后执行sp_configure
命令调整)。
sudo docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=YourStrongPassword' -p 1433:1433 --name sqlserver -d mcr.microsoft.com/mssql/server:2022-latest
查阅SQL Server官方Linux文档(重点关注Debian相关备注)及Debian社区论坛(如Ask Ubuntu、Stack Overflow),获取最新兼容性更新和故障排查经验。