1
Database:SQLServer
Jeffery edited this page 2026-03-06 02:49:40 +00:00
This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

安裝相關套件

apt update && apt install -y curl

安裝加密簽證

curl https://packages.microsoft.com/keys/microsoft.asc | tee /etc/apt/trusted.gpg.d/microsoft.asc

安裝套件列表

curl -fsSL https://packages.microsoft.com/config/ubuntu/22.04/mssql-server-2022.list | tee /etc/apt/sources.list.d/mssql-server-2022.list

安裝 SQL Server

apt update && apt install -y mssql-server

安裝缺少的套件

wget http://archive.ubuntu.com/ubuntu/pool/main/o/openldap/libldap-2.5-0_2.5.11+dfsg-1~exp1ubuntu3_amd64.deb && dpkg -i libldap-2.5-0_2.5.11+dfsg-1~exp1ubuntu3_amd64.deb

設定 SQL Server

密碼

/opt/mssql/bin/mssql-conf setup

代理

啟用代理後重啟服務

/opt/mssql/bin/mssql-conf set sqlagent.enabled true && systemctl restart mssql-server

定序

停止服務

systemctl stop mssql-server

設定定序

/opt/mssql/bin/mssql-conf set-collation
  • Chinese_Taiwan_Stroke_CI_AS以筆劃排序大小寫不區分 (Case Insensitive),重音符號區分 (Accent Sensitive),適合一般文字搜尋。

  • Chinese_Taiwan_Stroke_CS_AS以筆劃排序大小寫區分 (Case Sensitive),重音符號區分,適合需要區分大小寫的場景。

啟動服務

systemctl start mssql-server

連接埠 1433

安裝 sqlcmd 加密簽證

curl https://packages.microsoft.com/keys/microsoft.asc | tee /etc/apt/trusted.gpg.d/microsoft.asc

安裝 sqlcmd 套件列表

curl https://packages.microsoft.com/config/ubuntu/18.04/prod.list | tee /etc/apt/sources.list.d/mssql-release.list

安裝 sqlcmd

apt update && apt install -y mssql-tools18 unixodbc-dev

設定環境變數

echo 'export PATH="$PATH:/opt/mssql-tools18/bin"' >> ~/.bashrc && source ~/.bashrc