SQLLocalDB不会启动并引发错误,如下所示。
**C:\Windows\system32>sqllocaldb c MSSQLLocalDB**
Creation of LocalDB instance "MSSQLLocalDB" failed because of the following error:
Error occurred during LocalDB instance startup: SQL Server process failed to start.
***Note:*** Command started with Run as Administrator.
事件查看器显示如下日志:
Windows API call WaitForMultipleObjects returned error code: 575. Windows system error message is: {Application Error}
The application was unable to start correctly (0x%lx). Click OK to close the application.
Reported at line: 3714.
Source: SQLLocalDB 15.0
Event ID: 528
Level: Error
操作系统: Windows 11 Pro build 22000.832
安装的版本: Microsoft 2019 (15.0.4153.1)
从VisualStudio2022版本17.2.6连接SQLLocalDB时,它显示了以下消息:
TITLE: Error
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 50 - Local Database Runtime error occurred. Error occurred during LocalDB instance startup: SQL Server process failed to start.
) (Microsoft SQL Server, Error: -1983577846)
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft%20SQL%20Server&EvtSrc=MSSQLServer&EvtID=-1983577846&LinkId=20476
------------------------------
Error Number: -1983577846
Severity: 20
State: 0
下面的是:文件中的详细信息
2022-07-28 12:13:11.50 Server Microsoft SQL Server 2019 (RTM-CU12) (KB5004524) - 15.0.4153.1 (X64)
Jul 19 2021 15:37:34
Copyright (C) 2019 Microsoft Corporation
Express Edition (64-bit) on Windows 10 Pro 10.0 <X64> (Build 22000: )
2022-07-28 12:13:11.50 Server UTC adjustment: 5:30
2022-07-28 12:13:11.50 Server (c) Microsoft Corporation.
2022-07-28 12:13:11.50 Server All rights reserved.
2022-07-28 12:13:11.50 Server Server process ID is 10072.
2022-07-28 12:13:11.50 Server System Manufacturer: 'LENOVO', System Model: '82KB'.
2022-07-28 12:13:11.50 Server Authentication mode is MIXED.
2022-07-28 12:13:11.50 Server Logging SQL Server messages in file 'C:\Users\<user>\AppData\Local\Microsoft\Microsoft SQL Server Local DB\Instances\MSSQLLocalDB\error.log'.
2022-07-28 12:13:11.50 Server The service account is '<domain\user>'. This is an informational message; no user action is required.
2022-07-28 12:13:11.50 Server Command Line Startup Parameters:
-c
-S "MSSQL15E.LOCALDB"
-s "LOCALDB#C0C8C320"
-d "C:\Users\<user>\AppData\Local\Microsoft\Microsoft SQL Server Local DB\Instances\MSSQLLocalDB\master.mdf"
-l "C:\Users\<user>\AppData\Local\Microsoft\Microsoft SQL Server Local DB\Instances\MSSQLLocalDB\mastlog.ldf"
-e "C:\Users\<user>\AppData\Local\Microsoft\Microsoft SQL Server Local DB\Instances\MSSQLLocalDB\error.log"
2022-07-28 12:13:11.51 Server SQL Server detected 1 sockets with 4 cores per socket and 8 logical processors per socket, 8 total logical processors; using 8 logical processors based on SQL Server licensing. This is an informational message; no user action is required.
2022-07-28 12:13:11.51 Server SQL Server is starting at normal priority base (=7). This is an informational message only. No user action is required.
2022-07-28 12:13:11.51 Server Detected 16183 MB of RAM. This is an informational message; no user action is required.
2022-07-28 12:13:11.51 Server Using conventional memory in the memory manager.
2022-07-28 12:13:11.51 Server Page exclusion bitmap is enabled.
2022-07-28 12:13:11.64 Server Buffer Pool: Allocating 2097152 bytes for 1740277 hashPages.
2022-07-28 12:13:11.66 Server Default collation: SQL_Latin1_General_CP1_CI_AS (us_english 1033)
2022-07-28 12:13:11.67 Server Buffer pool extension is already disabled. No action is necessary.
2022-07-28 12:13:11.70 Server Query Store settings initialized with enabled = 1,
2022-07-28 12:13:11.70 Server The maximum number of dedicated administrator connections for this instance is '1'
2022-07-28 12:13:11.70 Server Node configuration: node 0: CPU mask: 0x00000000000000ff:0 Active CPU mask: 0x00000000000000ff:0. This message provides a description of the NUMA configuration for this computer. This is an informational message only. No user action is required.
2022-07-28 12:13:11.70 Server Using dynamic lock allocation. Initial allocation of 2500 Lock blocks and 5000 Lock Owner blocks per node. This is an informational message only. No user action is required.
2022-07-28 12:13:11.71 Server In-Memory OLTP initialized on standard machine.
2022-07-28 12:13:11.71 Server [INFO] Created Extended Events session 'hkenginexesession'
2022-07-28 12:13:11.71 Server Database Instant File Initialization: disabled. For security and performance considerations see the topic 'Database Instant File Initialization' in SQL Server Books Online. This is an informational message only. No user action is required.
2022-07-28 12:13:11.72 Server Total Log Writer threads: 2. This is an informational message; no user action is required.
2022-07-28 12:13:11.73 Server clwb is selected for pmem flush operation.
2022-07-28 12:13:11.73 Server Software Usage Metrics is disabled.
2022-07-28 12:13:11.74 spid9s Starting up database 'master'.
2022-07-28 12:13:11.75 spid9s There have been 256 misaligned log IOs which required falling back to synchronous IO. The current IO is on file C:\Users\<user>\AppData\Local\Microsoft\Microsoft SQL Server Local DB\Instances\MSSQLLocalDB\master.mdf.
到目前为止,尝试过:我已经尝试删除SSIS、VS、注册表键、文件夹等。甚至我也再次安装了干净的Windows 11,以避免残留文件/registry post卸载的问题。
我的域帐户已在此计算机上的管理员组中。但我还另外添加了sysadmin。文件夹已经有足够的权限来存放MDF文件。
发布于 2022-08-27 17:38:01
我的设置和问题与您在Localdb实例中列出的相同,包括相同的Server错误日志。
Microsoft docs中的以下故障排除文章提供了一个修复程序。
https://learn.microsoft.com/en-us/troubleshoot/sql/admin/troubleshoot-os-4kb-disk-sector-size
文章中的“场景2”描述了您发布的错误日志中列出的错误消息。
2021-11-05 23:42:47.14 spid9s中有256个log IOs不对齐,需要回到同步IO。当前IO位于文件C:\Program \Microsoft Server\MSSQL15.MSSQLSERVER\MSSQL\DATA\master.mdf.上
根据该条的原因一节:
在服务启动期间,Server将开始数据库恢复过程,以确保数据库的一致性。数据库恢复过程的一部分是在尝试打开系统和用户数据库文件之前对底层文件系统进行一致性检查。 在运行Windows 11的系统上,一些新的存储设备和设备驱动程序将公开大于支持的4KB扇区大小的磁盘扇区大小。 当发生这种情况时,由于不支持的文件系统,Server将无法启动,因为Server当前支持512字节和4KB的扇区存储大小。
故障排除条款中的“解决方案”部分指出:
微软目前正在调查这个问题。考虑以下解决方案之一:
我使用了以下步骤,并解决了这个问题:
您可以添加一个注册表项,它将导致Windows 11及更高版本的行为类似于Windows 10。这将迫使扇区大小模拟为4KB大小。若要添加ForcedPhysicalSectorSizeInBytes注册表项,请使用注册表编辑器,或者可以在Windows命令提示符或作为管理员执行的PowerShell中运行下列命令之一。
在注册表项生成后重新启动计算机。我必须删除现有的mssqllocaldb,并在重新启动我的机器后重新创建它。从命令提示符作为管理员
Sqllocaldb delete mssqllocaldb
Sqllocaldb create mssqllocaldb -s
此链接还描述了与故障排除文章相同的问题。我在使用新的三星笔记本电脑时遇到了Server启动失败的问题。
https://stackoverflow.com/questions/73148657
复制相似问题