三星m.2固态硬盘 Windows11 安装 Sqlserver 2019 失败的问题以及解决方案
无论是sqlserver localdb还是 sqlServer 的其它版本,在windows11下,安装后都无法启动 sqlservr.exe, 总之就是各种错误
后来多方搜索查询,发现好像是三星的m.2 ssd问题..我用的是三星980 m.2 恰好中招
再后来,经过多方搜索和查询发现下面这个帖子
https://docs.microsoft.com/en-us/answers/questions/668708/ssd-showing-incorrect-bytes-per-sector-win-11-sql.html
用powershell运行下面这个命令,果然显示的异常(这两个32768导致的sqlserver出错)
fsutil fsinfo sectorinfo c:
PS C:\Windows\system32> fsutil fsinfo sectorinfo c: LogicalBytesPerSector : 512 PhysicalBytesPerSectorForAtomicity : 32768 PhysicalBytesPerSectorForPerformance : 32768 FileSystemEffectivePhysicalBytesPerSectorForAtomicity : 4096 设备校准 : 已校准(0x000) 设备上的分区校准: 已校准(0x000) 无搜寻惩罚 支持剪裁 不支持 DAX 未精简预配 PS C:\Windows\system32>
解决方案就是执行以下命令(powershell或者bat都行,但是要以管理员身份)
reg add "HKLM\SYSTEM\CurrentControlSet\Services\stornvme\Parameters\Device" /v "ForcedPhysicalSectorSizeInBytes" /t reg_multi_sz /d "* 4095" /f
重启之后再看 fsutil fsinfo sectorinfo c: 就正常了...
PS C:\Windows\system32> fsutil fsinfo sectorinfo c: LogicalBytesPerSector : 512 PhysicalBytesPerSectorForAtomicity : 4096 PhysicalBytesPerSectorForPerformance : 4096 FileSystemEffectivePhysicalBytesPerSectorForAtomicity : 4096 设备校准 : 已校准(0x000) 设备上的分区校准: 已校准(0x000) 无搜寻惩罚 支持剪裁 不支持 DAX 未精简预配 PS C:\Windows\system32>
接下来随便怎么安装启动都没有问题了..
还有一个就是localdb,可能需要把当前登录的用户,加入到users用户组,否则可能还会出现各种异常
1.将当前的用户名加入到Users组里
2.使用这个命令 sqllocaldb d MSSQLLocalDB 将之前的默认数据库删除
3.使用这个命令 重新建立一个数据库 sqllocaldb c MSSQLLocalDB -s
4.打开 ssms, 服务器名称里填 (localdb)\MSSQLLocalDB 身份验证使用 windows身份验证
5.enjoy