日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
Ubuntu下部署SQLServer2017

SQL Server 2017 最近已正式發(fā)布。這是 SQL Server 歷史上***同時發(fā)布 Windows 和 Linux 版。此外,微軟還發(fā)布了能使用 Docker 部署的容器版本。對 SQL Server 而言,這是其歷史上具有里程碑意義的一步,因為這是跨出 Windows 的***個版本,標(biāo)志著 SQL Server 在 Linux 平臺上***可用。

專注于為中小企業(yè)提供網(wǎng)站設(shè)計制作、成都網(wǎng)站制作服務(wù),電腦端+手機端+微信端的三站合一,更高效的管理,為中小企業(yè)霞浦免費做網(wǎng)站提供優(yōu)質(zhì)的服務(wù)。我們立足成都,凝聚了一批互聯(lián)網(wǎng)行業(yè)人才,有力地推動了上千企業(yè)的穩(wěn)健成長,幫助中小企業(yè)通過網(wǎng)站建設(shè)實現(xiàn)規(guī)模擴充和轉(zhuǎn)變。

SQL Server 2017 新版本成為***個云端、跨不同操作系統(tǒng)的版本,包括 Linux、Docker。SQL Server 2017 目前支持的 Linux 發(fā)行版包括:Red Hat Enterprise Linux(RHEL), SUSE Linux Enterprise Server 和 Ubuntu。SQL Server 2017 支持 Docker 企業(yè)版,Kubernetes 和 OpenShift 這三大容器平臺。

SQL Server 2017 新特性

  • SQL Server 2017 支持使用 R 和 Python 的分析方法,來做資料庫內(nèi)的機器學(xué)習(xí),意味著不必遷移資料,省下不少時間。
  • 圖數(shù)據(jù)分析功能將使客戶能夠使用圖形數(shù)據(jù)存儲和查詢語言擴展來使用原生的圖形查詢語法,以便在高度互連的數(shù)據(jù)中發(fā)現(xiàn)新的關(guān)系。
  • 自適應(yīng)查詢處理可為數(shù)據(jù)庫帶來更智能的體驗。例如,SQL Server 中的 Adaptive Memory Grants 跟蹤并了解對給定的查詢使用了多少內(nèi)存,以調(diào)整內(nèi)存的使用。
  • Automatic Plan Correction 通過查找和修正性能的回歸來確保持續(xù)的性能。

SQL Server 2017 的核心功能在 Windows 和 Linux 上保持一致,但有少部分依賴于 Windows 功能的特性沒有提供給 Linux (例如集群支持和集成 Windows 身份驗證)。

本文將介紹如何在 Ubuntu 下部署 SQL Server 2017 。

安裝 SQL Server 2017

在 Linux 上 安裝 SQL Server 2017 的先決條件

設(shè)備類型 設(shè)備要求
內(nèi)存3.25 GB 及以上
文件系統(tǒng)XFS或EXT4 (其他文件系統(tǒng),如BTRFS,不支持)
磁盤空間6 GB
處理器速度2 GHz
處理器核心2 核
處理器類型僅 x64 兼容

安裝 SQL Server 2017 服務(wù)端

  • 導(dǎo)入公共存儲庫 GPG 密鑰
 
 
 
 
  1. $ curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add - 
  • 增加 Microsoft SQL Server Ubuntu 倉庫
 
 
 
 
  1. $ add-apt-repository "$(curl https://packages.microsoft.com/config/ubuntu/16.04/mssql-server-2017.list)" 
  • 安裝 SQL Server 服務(wù)端
 
 
 
 
  1. $ apt-get update 
  2. $ apt-get install -y mssql-server  
  • 設(shè)置 SA 密碼,并選擇要安裝的版本
 
 
 
 
  1. $ /opt/mssql/bin/mssql-conf setup 
  2.  
  3. Choose an edition of SQL Server: 
  4. 1) Evaluation (free, no production use rights, 180-day limit) 
  5. 2) Developer (free, no production use rights) 
  6. 3) Express (free) 
  7. 4) Web (PAID) 
  8. 5) Standard (PAID) 
  9. 6) Enterprise (PAID) 
  10. 7) Enterprise Core (PAID) 
  11. 8) I bought a license through a retail sales channel and have a product key to enter. 
  12.  
  13. Details about editions can be found at 
  14. https://go.microsoft.com/fwlink/?LinkId=852748&clcid=0x409 
  15.  
  16. Use of PAID editions of this software requires separate licensing through a 
  17. Microsoft Volume Licensing program. 
  18. By choosing a PAID edition, you are verifying that you have the appropriate 
  19. number of licenses in place to install and run this software. 
  20.  
  21. Enter your edition(1-8): 1 
  22. The license terms for this product can be found in 
  23. /usr/share/doc/mssql-server or downloaded from: 
  24. https://go.microsoft.com/fwlink/?LinkId=855864&clcid=0x409 
  25.  
  26. The privacy statement can be viewed at: 
  27. https://go.microsoft.com/fwlink/?LinkId=853010&clcid=0x409 
  28.  
  29. Do you accept the license terms? [Yes/No]:yes 
  30.  
  31. Enter the SQL Server system administrator password: 
  32. Confirm the SQL Server system administrator password: 
  33. Configuring SQL Server... 
  34.  
  35. The licensing PID was successfully processed. The new edition is [Enterprise Evaluation Edition]. 
  36. Created symlink from /etc/systemd/system/multi-user.target.wants/mssql-server.service to /lib/systemd/system/mssql-server.service. 
  37. Setup has completed successfully. SQL Server is now starting.  

一共提供了 8 個版本供選擇,其中自由授予許可版本有:評估、開發(fā)人員和快速。

SA 帳戶必須為強密碼(最少 8 個字符,包括大寫和小寫字母、十進制數(shù)字和/或非字母數(shù)字符號)。

  • 驗證服務(wù)是否正在運行
 
 
 
 
  1. $ systemctl status mssql-server 
  2.  
  3. ● mssql-server.service - Microsoft SQL Server Database Engine 
  4. Loaded: loaded (/lib/systemd/system/mssql-server.service; enabled; vendor preset: enabled) 
  5. Active: active (running) since Thu 2017-10-12 11:50:29 CST; 1min 22s ago 
  6. Docs: https://docs.microsoft.com/en-us/sql/linux 
  7. Main PID: 20776 (sqlservr) 
  8. CGroup: /system.slice/mssql-server.service 
  9. ├─20776 /opt/mssql/bin/sqlservr 
  10. └─20796 /opt/mssql/bin/sqlservr  

安裝 SQL Server 2017 命令行工具

如果要創(chuàng)建數(shù)據(jù)庫,需要使用客戶端工具 sqlcmd 和 bcp。

  • 導(dǎo)入公共存儲庫 GPG 密鑰
 
 
 
 
  1. $ curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add - 
  • 增加 Microsoft Ubuntu 倉庫
 
 
 
 
  1. $ add-apt-repository "$(curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list)" 
  • 安裝 SQL Server 命令行工具 和 unixODBC 開發(fā)人員工具包
 
 
 
 
  1. $ apt-get update 
  2. $ apt-get install -y mssql-tools unixodbc-dev  

Sqlcmd 工具默認安裝到 /opt/mssql-tools/bin/ 中的,為方便使用把 /opt/mssql-tools/bin/ 添加到環(huán)境變量中。

 
 
 
 
  1. $ echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile 
  2. $ echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc 
  3. $ source ~/.bashrc  

Sqlcmd 是用于連接到 SQL Server 以運行查詢并執(zhí)行管理和開發(fā)的一個命令行工具。如果要使用功能更強大的圖形工具,可使用 SQL Server Management Studio 或 Visual Studio Code 的 mssql 插件。

  • 使用 Sqlcmd 建立本地連接

Sqlcmd 連接到本地的 SQL Server 實例。密碼是在安裝過程中配置的 SA 帳戶密碼。

 
 
 
 
  1. $ sqlcmd -S localhost -U SA -P '

參數(shù)說明

  • -S 連接 SQL Server 的機器名
  • -U 連接 SQL Server 的用戶名
  • -P 連接 SQL Server 的密碼

連接成功,應(yīng)會顯示 Sqlcmd 命令提示符:1>,就類似下面這樣

 
 
 
 
  1. $ sqlcmd -S localhost -U SA 
  2. Password: 
  3. 1>  

創(chuàng)建數(shù)據(jù)庫和查詢數(shù)據(jù)

新建數(shù)據(jù)庫

  • 創(chuàng)建一個名為 TestDB 的新數(shù)據(jù)庫

在 sqlcmd 命令提示符中,執(zhí)行 Transact-SQL 命令以創(chuàng)建測試數(shù)據(jù)庫。

 
 
 
 
  1. 1> CREATE DATABASE TestDB 

在 SQL Server 中 命令并沒有立即執(zhí)行, 必須在新行中鍵入 GO 才能執(zhí)行命令。

 
 
 
 
  1. 2> GO 
  • 返回服務(wù)器上所有數(shù)據(jù)庫的名稱
 
 
 
 
  1. 1> SELECT Name from sys.Databases 
  2. 2> GO 
  3. Name 
  4. ---------------------------------------- 
  5. master 
  6. tempdb 
  7. model 
  8. msdb 
  9. TestDB 
  10.  
  11. (5 rows affected)  

插入數(shù)據(jù)

  • 創(chuàng)建一個新表 Inventory,然后插入兩個新行。

在 sqlcmd 命令提示符中,切換到新的 TestDB 數(shù)據(jù)庫。

 
 
 
 
  1. 1> USE TestDB 

創(chuàng)建名為 Inventory 的新表

 
 
 
 
  1. 2> CREATE TABLE Inventory (id INT, name NVARCHAR(50), quantity INT) 

將數(shù)據(jù)插入新表

 
 
 
 
  1. 3> INSERT INTO Inventory VALUES (1, 'banana', 150); INSERT INTO Inventory VALUES (2, 'orange', 154); 

批量執(zhí)行上述命令

 
 
 
 
  1. 4> GO 

整個執(zhí)行過程如下

 
 
 
 
  1. 1> USE TestDB 
  2. 2> CREATE TABLE Inventory (id INT, name NVARCHAR(50), quantity INT) 
  3. 3> INSERT INTO Inventory VALUES (1, 'banana', 150); INSERT INTO Inventory VALUES (2, 'orange', 154); 
  4. 4> GO 
  5. Changed database context to 'TestDB'. 
  6.  
  7. (1 rows affected) 
  8.  
  9. (1 rows affected)  
  • 查詢數(shù)據(jù)

通過 sqlcmd 命令查詢 Inventory 表中數(shù)量大于 152 的行

 
 
 
 
  1. 1> SELECT * FROM Inventory WHERE quantity > 152; 
  2. 2> GO 
  3. id          name         quantity 
  4. ------ ------------ ----------- 
  5. 2 orange       154 
  6.  
  7. (1 rows affected)  
  • 退出 sqlcmd

要結(jié)束 sqlcmd 會話,請鍵入 QUIT。

 
 
 
 
  1. 1> QUIT 

卸載 SQL Server 2017

若要刪除 SQL Server 2017,可使用以下命令

 
 
 
 
  1. $ apt-get remove mssql-server 

刪除包不會刪除生成的數(shù)據(jù)庫文件。 如果你想要刪除的數(shù)據(jù)庫文件,可使用以下命令

 
 
 
 
  1. $ sudo rm -rf /var/opt/mssql/ 

***在推薦下微軟良心出品 Visual Studio Code 這個編輯器,功能異常強大、跨平臺并且是開源的。最最最重要的是它比 Atom 快,插件也很豐富。我已從 Atom 轉(zhuǎn)坑入 VSCode了,感謝蝸牛大神的推薦!

下圖為 VSCode+MSSQL 插件的效果圖,有沒有很贊的~ 

參考文檔

http://www.google.com

https://docs.microsoft.com/en-us/sql/linux/quickstart-install-connect-ubuntu 


當(dāng)前標(biāo)題:Ubuntu下部署SQLServer2017
URL分享:http://m.5511xx.com/article/dpospoh.html