1. 程式人生 > >阿里雲 Windows Server Version 資料中心版(不含UI) 安裝MSSQL資料庫

阿里雲 Windows Server Version 資料中心版(不含UI) 安裝MSSQL資料庫

   由於本人安裝的是SQL server-2017 Developer版,此文也僅以此版本的為例.首先需要下載SQL server安裝包.下載之後會得到一個{SQLServer2017-SSEI-Dev.exe}Exe檔案,雙擊該EXE程式,選擇{下載介質}下載SQL server 完整安裝包,為了方便建議選擇{CAB}下載完成之後會得到兩個同名的檔案

將下載的兩個檔案通過FileZilla上傳到伺服器(在伺服器安裝FileZilla),在伺服器上找到{SQLServer2017-DEV-x64-CHS.exe}右鍵執行,將BOX檔案解壓.解壓完成之後我們需要準備安裝時需要的配置檔案:如下;可根據需要修改引數;

; SQL Server Configuration File  
[OPTIONS]  
; Specifies a Setup work flow, like INSTALL, UNINSTALL, or UPGRADE. This is a required parameter.   
ACTION="Install"  
; Specifies features to install, uninstall, or upgrade. The lists of features include SQLEngine, FullText, Replication, AS, IS, and Conn.   
FEATURES=SQLENGINE,FullText,Replication,AS,IS,Conn  
; Specify a default or named instance. MSSQLSERVER is the default instance for non-Express editions and SQLExpress for Express editions. This parameter is required when installing the ssNoVersion Database Engine (SQL), or Analysis Services (AS).  
INSTANCENAME="MSSQLSERVER"  
; Specify the Instance ID for the ssNoVersion features you have specified. ssNoVersion directory structure, registry structure, and service names will incorporate the instance ID of the ssNoVersion instance.   
INSTANCEID="MSSQLSERVER"  
; Account for ssNoVersion service: Domain\User or system account.   
SQLSVCACCOUNT="NT Service\MSSQLSERVER"  
; Windows account(s) to provision as ssNoVersion system administrators.   
SQLSYSADMINACCOUNTS="\<DomainName\UserName>";//這裡需要根據各自的環境進行修改
; The name of the account that the Analysis Services service runs under.   
ASSVCACCOUNT= "NT Service\MSSQLServerOLAPService"  
; Specifies the list of administrator accounts that need to be provisioned.   
ASSYSADMINACCOUNTS="\<DomainName\UserName>";//這裡需要根據各自的環境進行修改
; Specifies the server mode of the Analysis Services instance. Valid values are MULTIDIMENSIONAL, POWERPIVOT or TABULAR. ASSERVERMODE is case-sensitive. All values must be expressed in upper case.   
ASSERVERMODE="MULTIDIMENSIONAL"  
; Optional value, which specifies the state of the TCP protocol for the ssNoVersion service. Supported values are: 0 to disable the TCP protocol, and 1 to enable the TCP protocol.  
TCPENABLED=1  
;Specifies acceptance of License Terms  
IAcceptSQLServerLicenseTerms="True"

配置檔案準備好之後儲存為{.INI}格式;如{ConfigurationFile.INI},然後將檔案上傳到伺服器,為了方便,我將檔案上傳到Sql Server安裝目錄

C:/Installapp/SQLServer2017-DEV-x64-CHS/setup.exe /qs /ConfigurationFile=C:/Installapp/SQLServer2017-DEV-x64-CHS/ConfigurationFile.INI

安裝完成之後暫時是沒辦法在客戶端通過SSMS工具連線到我們的資料庫的,我們需要做以下配置;首先啟用{SQL server和Windows身份驗證模式}:在伺服器的powershell中輸入{regedit}開啟登錄檔;依次找到{HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL14.MSSQLSERVER\MSSQLServer}將LoginMode值修改為{2},然後重啟{SQLSERVER}服務.然後通過一下命令啟用{sa}賬戶,並設定密碼

sqlcmd
#檢視sa 賬戶是否啟用
SELECT name, type, is_disabled FROM sys.server_principals
go
#啟用sa賬戶
ALTER LOGIN sa ENABLE
go
#設定sa賬戶密碼
ALTER LOGIN sa WITH PASSWORD='xxxxxxxxxxxxxx'
go

處理完成之後,沒有其問題,應該就可以通過SSMT工具在客戶端上來連線資料庫了.