You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

无法启动MSSQLLocalDB:ASP.NET项目数据库连接故障求助

故障描述

我正在完成学校项目,使用Visual Studio 2022默认安装环境,采用ASP.NET(非Core)框架,在尝试创建数据库或连接现有数据库时出现错误。

核心错误提示

A network-related or instance-specific error occurred while establishing a connection to SQL Server. 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.

详细日志信息

  • MSSQLLocalDB错误日志最后一行:

    There have been 256 misaligned log IOs which required falling back to synchronous IO, The current file is on \MSSQLLocalDB\master.mdf

  • 事件查看器记录:

    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

  • 执行命令sqllocaldb start MSSQLLocalDB后的反馈:

    Start of LocalDB instance "MSSQLLocalDB" failed because of the following error:
    Error occurred during LocalDB instance startup: SQL Server process failed to start

已尝试无效操作

卸载所有与Visual Studio和Microsoft SQL Server相关的文件夹,重新安装后问题仍未解决。


解决方案

1. 重建LocalDB实例

以管理员权限打开命令提示符,依次执行以下命令:

sqllocaldb stop MSSQLLocalDB
sqllocaldb delete MSSQLLocalDB
sqllocaldb create MSSQLLocalDB
sqllocaldb start MSSQLLocalDB

该操作会彻底清除损坏的实例文件,重新生成干净的MSSQLLocalDB环境,解决master数据库文件损坏导致的IO对齐问题。

2. 修复磁盘权限与系统设置

  • 定位LocalDB数据目录(默认路径:C:\Users\<你的用户名>\AppData\Local\Microsoft\Microsoft SQL Server Local DB\Instances\MSSQLLocalDB),右键目录选择「属性」→「安全」,确保当前用户拥有完全控制权限。
  • 关闭Windows快速启动:打开「控制面板」→「电源选项」→「选择电源按钮的功能」→「更改当前不可用的设置」,取消勾选「启用快速启动」,重启电脑后重试。

3. 重新安装LocalDB组件

打开Visual Studio Installer,选择「修改」,在「工作负载」中找到「数据存储和处理」,确保勾选「SQL Server Express LocalDB」,点击「修改」重新安装该组件(无需卸载整个Visual Studio)。

4. 检查系统服务状态

  • 按Win+R输入services.msc打开服务管理器,确认「SQL Server VSS Writer」服务设置为自动启动,若未启动则手动启动。
  • 确保「Windows Event Log」服务正常运行,LocalDB启动依赖该服务记录运行日志。

5. 替换损坏的master数据库文件

若重建实例无效,可从正常运行LocalDB的设备上复制master.mdf和mastlog.ldf文件,替换本地对应目录下的损坏文件(替换前需执行sqllocaldb stop MSSQLLocalDB停止实例)。


内容的提问来源于stack exchange,提问作者ChanZY

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.04 15:25:12