数据库引擎服务启动选项Database Engine Service Startup Options

适用对象: yesSQL ServeryesAzure SQL 数据库noAzure SQL 数据仓库no并行数据仓库APPLIES TO: yesSQL Server noAzure SQL Database noAzure SQL Data Warehouse noParallel Data Warehouse

启动选项指定在启动期间所需的某些文件位置,并指定一些服务器范围的条件。Startup options designate certain file locations needed during startup, and specify some server wide conditions. 大多数用户不需要指定启动选项,除非您在排除 数据库引擎Database Engine 故障或者具有不常见问题,并且 SQL ServerSQL Server 客户支持指示使用启动选项。Most users do not need to specify startup options unless you are troubleshooting the 数据库引擎Database Engine or you have an unusual problem and are directed to use a startup option by SQL ServerSQL Server Customer Support.

警告

错误地使用启动选项可能会影响服务器性能并且可能阻止 SQL ServerSQL Server 启动。Improper use of startup options can affect server performance and can prevent SQL ServerSQL Server from starting.

使用“mssql”用户启动 Linux 上的 SQL Server 以防止将来的启动问题。Start SQL Server on Linux with the "mssql" user to prevent future startup issues. 例如:sudo -u mssql /opt/mssql/bin/sqlservr [STARTUP OPTIONS]Example: sudo -u mssql /opt/mssql/bin/sqlservr [STARTUP OPTIONS]

关于启动选项About Startup Options

安装 SQL ServerSQL Server时,安装程序会将一组默认的启动选项写入 MicrosoftMicrosoft Windows 注册表。When you install SQL ServerSQL Server, Setup writes a set of default startup options in the MicrosoftMicrosoft Windows registry. 可以使用这些启动选项指定备用的 master 数据库文件、master 数据库日志文件或错误日志文件。You can use these startup options to specify an alternate master database file, master database log file, or error log file. 如果 数据库引擎Database Engine 找不到所需文件, SQL ServerSQL Server 将不启动。If the 数据库引擎Database Engine cannot locate the necessary files, SQL ServerSQL Server will not start.

可以使用 SQL ServerSQL Server 配置管理器设置启动选项。Startup options can be set by using SQL ServerSQL Server Configuration Manager. 有关信息,请参阅配置服务器启动选项 (SQL Server Configuration Manager)For information, see Configure Server Startup Options (SQL Server Configuration Manager).

启动选项列表List of Startup Options

默认启动选项Default startup options

选项Options 描述Description
-d master_file_path-d master_file_path 是 master 数据库文件的完全限定路径(通常为:C:\Program Files\Microsoft SQL Server\MSSQL.n\MSSQL\Data\master.mdf)。Is the fully qualified path for the master database file (typically, C:\Program Files\Microsoft SQL Server\MSSQL.n\MSSQL\Data\master.mdf). 如果没有提供此选项,则使用现有的注册表参数。If you do not provide this option, the existing registry parameters are used.
-e error_log_path-e error_log_path 是错误日志文件的完全限定路径(通常为 C:\Program Files\Microsoft SQL Server\MSSQL.n\MSSQL\LOG\ERRORLOG)。Is the fully qualified path for the error log file (typically, C:\Program Files\Microsoft SQL Server\MSSQL.n\MSSQL\LOG\ERRORLOG). 如果没有提供此选项,则使用现有的注册表参数。If you do not provide this option, the existing registry parameters are used.
-l master_log_path-l master_log_path 是 master 数据库日志文件的完全限定路径(通常为:C:\Program Files\Microsoft SQL Server\MSSQL.n\MSSQL\Data\mastlog.ldf)。Is the fully qualified path for the master database log file (typically C:\Program Files\Microsoft SQL Server\MSSQL.n\MSSQL\Data\mastlog.ldf). 如果没有指定此选项,则使用现有的注册表参数。If you do not specify this option, the existing registry parameters are used.

其他启动选项Other startup options

选项Options 描述Description
-c-c 缩短从命令提示符启动 SQL ServerSQL Server 时的启动时间。Shortens startup time when starting SQL ServerSQL Server from the command prompt. 通常, SQL Server 数据库引擎SQL Server Database Engine 通过调用服务控制管理器作为服务启动。Typically, the SQL Server 数据库引擎SQL Server Database Engine starts as a service by calling the Service Control Manager. 由于在通过命令提示符启动时 SQL Server 数据库引擎SQL Server Database Engine 不作为服务启动,因此请使用 -c 跳过此步骤。Because the SQL Server 数据库引擎SQL Server Database Engine does not start as a service when starting from the command prompt, use -c to skip this step.
-f-f 以最小配置启动 SQL ServerSQL Server 实例。Starts an instance of SQL ServerSQL Server with minimal configuration. 在配置值的设置(例如,过度分配内存)妨碍服务器启动时,这非常有用。This is useful if the setting of a configuration value (for example, over-committing memory) has prevented the server from starting. 在最低配置模式下启动 SQL ServerSQL Server 会将 SQL ServerSQL Server 置于单用户模式。Starting SQL ServerSQL Server in minimal configuration mode places SQL ServerSQL Server in single-user mode. 有关详细信息,请参阅下面的 -m 说明。For more information, see the description for -m that follows.
-kDecimalNumber-kDecimalNumber 此启动参数限制每秒检查点 I/O 请求的数量,其中 DecimalNumber 表示以 MB/S 为单位的检查点速度 。This startup parameter limits the number of checkpoint I/O requests per second, where the DecimalNumber represents the checkpoint speed in MB per second. 更改此值可能会影响备份速度或执行恢复过程,因此请谨慎操作。Changing this value can impact the speed of taking backups, or going through the recovery process so proceed with caution. 有关此启动参数的详细信息,请参阅修补程序中的 -k 参数介绍。For more information about this startup parameter, please see hot fix where the -k parameter was introduced.
-m-m 在单用户模式下启动 SQL ServerSQL Server 实例。Starts an instance of SQL ServerSQL Server in single-user mode. 在单用户模式下启动 SQL ServerSQL Server 实例时,只能连接一个用户,并且不启动 CHECKPOINT 进程。When you start an instance of SQL ServerSQL Server in single-user mode, only a single user can connect, and the CHECKPOINT process is not started. CHECKPOINT 保证将已完成的事务定期从磁盘缓存写入数据库设备。CHECKPOINT guarantees that completed transactions are regularly written from the disk cache to the database device. (通常,在遇到需要修复的系统数据库问题时使用此选项。)启用 sp_configure allow updates 选项。(Typically, this option is used if you experience problems with system databases that should be repaired.) Enables the sp_configure allow updates option. 默认情况下,allow updates 处于禁用状态。By default, allow updates is disabled. 在单用户模式下启动 SQL ServerSQL Server 可使计算机本地 Administrators 组的任何成员作为 sysadmin 固定服务器角色的成员连接到 SQL ServerSQL Server 实例。Starting SQL ServerSQL Server in single-user mode enables any member of the computer's local Administrators group to connect to the instance of SQL ServerSQL Server as a member of the sysadmin fixed server role. 有关详细信息,请参阅 在系统管理员被锁定时连接到 SQL Server。有关单用户模式的详细信息,请参阅 在单用户模式下启动 SQL ServerFor more information, see Connect to SQL Server When System Administrators Are Locked Out. For more information about single-user mode, see Start SQL Server in Single-User Mode.
-mClient 应用程序名称-mClient Application Name 将连接限制为指定的客户端应用程序。Limits the connections to a specified client application. 例如, -mSQLCMD 将连接限制为单个连接并且该连接必须将自身标识为 SQLCMD 客户端程序。For example, -mSQLCMD limits connections to a single connection and that connection must identify itself as the SQLCMD client program. 当您正在单用户模式下启动 SQL ServerSQL Server 并且未知的客户端应用程序正在占用这个唯一的可用连接时,使用此选项。Use this option when you are starting SQL ServerSQL Server in single-user mode and an unknown client application is taking the only available connection. 使用 "Microsoft SQL Server Management Studio - Query" 与 SSMS 查询编辑器连接。Use "Microsoft SQL Server Management Studio - Query" to connect with the SSMS Query Editor. SSMS 查询编辑器选项不能使用 SQL ServerSQL Server 配置管理器进行配置,因为它包括该工具拒绝使用的短划线字符。The SSMS Query Editor option cannot be configured by using SQL ServerSQL Server Configuration Manager because it includes the dash character which is rejected by the tool.

客户端应用程序名称区分大小写。Client Application Name is case sensitive. 如果应用程序名称包含空格或特殊字符,则需要使用双引号引起来。Double quotes are required if the application name contains spaces or special characters.

从命令行启动时的示例:Examples when starting from the command line:

C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\Binn\sqlservr -s MSSQLSERVER -m"Microsoft SQL Server Management Studio - Query"

C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\Binn\sqlservr -s MSSQLSERVER -mSQLCMD

安全说明: 不要将此选项作为安全功能使用。Security Note: Do not use this option as a security feature. 客户端应用程序提供客户端应用程序名称,并且提供假名称来作为连接字符串的一部分。The client application provides the client application name, and can provide a false name as part of the connection string.
-n-n 不要使用 Windows 应用程序日志来记录 SQL ServerSQL Server 事件。Does not use the Windows application log to record SQL ServerSQL Server events. 如果你使用 SQL ServerSQL Server -n 启动实例,我们建议你同时使用 -e 启动选项。If you start an instance of SQL ServerSQL Server with -n, we recommend that you also use the -e startup option. 否则,将不会记录 SQL ServerSQL Server 事件。Otherwise, SQL ServerSQL Server events are not logged.
-s-s 用于启动 SQL ServerSQL Server的命名实例。Allows you to start a named instance of SQL ServerSQL Server. 如果 -s 参数未设置,则系统会尝试启动默认实例。Without the -s parameter set, the default instance will try to start. 必须先在命令提示符处切换到实例的相应 BINN 目录,然后才能启动 sqlservr.exeYou must switch to the appropriate BINN directory for the instance at a command prompt before starting sqlservr.exe. 例如,如果 Instance1 为其二进制文件使用了 \mssql$Instance1,则用户必须位于 \mssql$Instance1\binn 目录中才能启动 sqlservr.exe -s instance1 。For example, if Instance1 were to use \mssql$Instance1 for its binaries, the user must be in the \mssql$Instance1\binn directory to start sqlservr.exe -s instance1.
-T trace#-T trace# 指示 SQL ServerSQL Server 实例启动时,指定的跟踪标志 (trace# ) 应同时生效。Indicates that an instance of SQL ServerSQL Server should be started with a specified trace flag (trace#) in effect. 跟踪标记用于以非标准行为启动服务器。Trace flags are used to start the server with nonstandard behavior. 有关详细信息,请参阅跟踪标志 (Transact-SQL)For more information, see Trace Flags (Transact-SQL).

重要提示: 使用 -T 选项指定跟踪标记时,请使用大写“T”来传递跟踪标记号 。Important: When specifying a trace flag with the -T option, use an uppercase "T" to pass the trace flag number. SQL ServerSQL Server也可接受小写“t”,只是它用于设置仅 SQL ServerSQL Server 支持工程师才需要的其他内部跟踪标志。A lowercase "t" is accepted by SQL ServerSQL Server, but this sets other internal trace flags that are required only by SQL ServerSQL Server support engineers. (不读取“控制面板”启动窗口中指定的参数。)(Parameters specified in the Control Panel startup window are not read.)
-x-x 禁用下列监视功能:Disables the following monitoring features:
- SQL ServerSQL Server 性能监视器计数器- SQL ServerSQL Server performance monitor counters
- 保留 CPU 时间和高速缓存命中率统计信息- Keeping CPU time and cache-hit ratio statistics
- 收集 DBCC SQLPERF 命令的信息- Collecting information for the DBCC SQLPERF command
- 收集某些动态管理视图的信息- Collecting information for some dynamic management views
- 许多扩展事件事件点- Many extended-events event points

警告: 使用 -x 启动选项时,可供用户用于诊断 SQL ServerSQL Server 的性能和功能问题的信息将显著减少 。Warning: When you use the -x startup option, the information that is available for you to diagnose performance and functional problems with SQL ServerSQL Server is greatly reduced.
-E-E 增加为文件组中的每个文件分配的区数。Increases the number of extents that are allocated for each file in a filegroup. 对于那些运行索引或数据扫描的用户数量受到限制的数据仓库应用程序,此选项可能十分有用。This option may be helpful for data warehouse applications that have a limited number of users running index or data scans. 不应在其他应用程序中使用此选项,因为它可能降低性能。It should not be used in other applications because it might adversely affect performance. 32 位版本的 SQL ServerSQL Server不支持此选项。This option is not supported in 32-bit releases of SQL ServerSQL Server.

使用启动选项进行故障排除Using Startup Options for Troubleshooting

某些启动选项(如单用户模式和最低配置模式)主要在故障排除过程中使用。Some startup options, such as single-user mode and minimal configuration mode, are principally used during troubleshooting. 使用“-m”或“-f”选项启动服务器进行故障排除的最简单方法是使用命令行,同时还能手动启动 sqlservr.exe 。Starting the server for troubleshooting with the -m or -f options is easiest at the command line, while manually starting sqlservr.exe.

备注

使用 SQL ServerSQL Server net start 启动时,启动选项使用的是左斜线 (/),而不是连字符 (-)。When SQL ServerSQL Server is started by using net start, startup options use a slash (/) instead of a hyphen (-).

在正常操作中使用启动选项Using Startup Options During Normal Operations

最好在每次启动 SQL ServerSQL Server时使用某些启动选项。You may want to use some startup options every time you start SQL ServerSQL Server. 完成这些选项(如用跟踪标志启动)的最简单方法是使用 SQL ServerSQL Server 配置管理器来配置启动参数。These options, such as starting with a trace flag, are most easily done by configuring the startup parameters by using SQL ServerSQL Server Configuration Manager. 这些工具将启动选项保存为注册表项,因此 SQL ServerSQL Server 将始终用这些启动选项来启动。These tool saves the startup options as registry keys, enabling SQL ServerSQL Server to always start with the startup options.

兼容性支持Compatibility Support

有关已从以前版本中删除的选项,请参阅 sqlservr 应用程序For options that have been removed from previous releases, see sqlservr Application.

配置 scan for startup procs 服务器配置选项Configure the scan for startup procs Server Configuration Option
启动、停止、暂停、继续、重新启动数据库引擎、SQL Server 代理或 SQL Server Browser 服务 配置服务器启动选项(SQL Server 配置管理器)Start, Stop, Pause, Resume, Restart the Database Engine, SQL Server Agent, or SQL Server Browser Service Configure Server Startup Options (SQL Server Configuration Manager)

另请参阅See Also

检查点 (Transact-SQL) CHECKPOINT (Transact-SQL)
sqlservr 应用程序sqlservr Application