部署免安装部署MSSQL:一步到位

1. 简介

在搭建开发环境时,可能需要使用到MSSQL数据库。部署MSSQL通常需要下载并安装SQL Server,但是这一过程较为繁琐。本文将介绍一种免安装部署MSSQL的方法,能够一步到位地完成MSSQL的部署。

2. 具体步骤

2.1 下载必要文件

下载并解压SQLServer2019-SSEI-Expr.exe 官方自带的含有 SQLServer 2019 Express 的 ISO 文件:

SQLServer2019-SSEI-Expr.iso

解压后,在解压后的包中找到如下文件:

Setup.exe

Data

2.2 修改安装配置文件

修改Data 目录下的 ConfigurationFile.ini:使用文本编辑器(例如Notepad)打开 ConfigurationFile.ini 文件,并加入如下配置:

    ; SQL Server 2019 Configuration File

[OPTIONS]

; Required to acknowledge acceptance of the license terms.

IACCEPTSQLSERVERLICENSETERMS="True"

; 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 list of top-level features include SQL, AS, RS, IS, and Tools. The SQL feature will install the database engine, replication, and full-text. The Tools feature will install Management Tools, Books online, Business Intelligence Development Studio, and other shared components.

FEATURES=SQLENGINE,REPLICATION

; Displays the command line parameters usage

HELP="False"

; Specifies that the detailed Setup log should be piped to the console.

INDICATEPROGRESS="False"

; Specifies that Setup should install into WOW64. This command line argument is not supported on an IA64 or a 32-bit system.

X64="False"

; Specifies the root installation directory for shared components.

INSTALLSHAREDDIR="C:\Program Files\Microsoft SQL Server"

; Specifies the root installation directory for the WOW64 shared components.

INSTALLSHAREDWOWDIR="C:\Program Files (x86)\Microsoft SQL Server"

; Specifies that the package should install without any user interface.

QUIET="True"

; Specifies the instance ID of the SQL Server features you have specified. SQL Server directory structure, registry structure, and service names will incorporate the instance ID of the SQL Server instance.

INSTANCEID="SQLEXPRESS"

; Specifies the SQL Server system administrator account username.

SQLSYSADMINACCOUNTS="AUTORITé NT\SERVICE\SQLSERVERAGENT"

; The password for the SQL Server system administrator account

; Description: Specify a strong password for the SQL Server system administrator account. The password complexity requirement depends on the edition of SQL Server: For Express or Express with Tools or Express with Advanced Services, password complexity is enforced based on the Windows operating system policies on the computer where SQL Server is installed. For all other editions of SQL Server, the password must meet these minimum requirements: Contains at least 8 characters. Contains characters from three of the following four sets: Uppercase letter (A-Z), Lowercase letter (a-z), Number (0-9) and Special character (!,$,#,%, etc.).

; Please note that this password will be used for all accounts created during installation. It is strongly recommend that you use a strong password. For more information, see Password Policy at http://go.microsoft.com/fwlink/?LinkId=189433.

SQLSYSADMINACCOUNTS="Automatically generated"

2.3 执行安装

打开Command Prompt作为管理员,并在其中输入以下命令:

Setup.exe /ConfigurationFile='D:\Downloads\Data\ConfigurationFile.ini'

其中‘D:\Downloads\’是你解压后的SQLServer2019-SSEI-Expr的路径。

接下来,就可以坐等SQL Server完成安装了。安装完毕后,会提示重启计算机。

2.4 配置SQL Server

成功安装 MSSQL 后,还需要配置 SQL Server 才能正常使用它。以下是配置步骤:

2.4.1 启动SQL Server

在开始菜单中搜索SSMS并打开,连接至本机内的 MSSQL 实例。

2.4.2 配置SQL Server身份验证模式

右键点击 MSSQL 实例,选择“属性”,并将身份验证模式更改为“SQL Server身份验证”。设置“sa”账户的密码,保存更改。

2.4.3 创建数据库

在 MSSQL 实例下创建数据库,以供后续开发使用。具体方法是右键点击“数据库”,选择“新建数据库”,并设置相关参数,如“数据库名”和“拥有者”等。

3. 总结

本文介绍了一种免安装完成 MSSQL 服务的方法。通过执行指定命令和简单的配置步骤,用户可以在不安装繁琐软件的前提下,搭建 MSSQL 环境。此方法需要用户熟悉基本的 SQL Server 开发知识,有一定的技术门槛,但能为开发者带来便利和节省时间成本的优势。

数据库标签