After reinstalling with data retained, the sqlserver database cannot start (sql2008, sql2012).
Published: 2019-10-17
Recently, many users have reported that after reinstalling to a system preinstalled with the sqlserver template, sqlserver cannot start normally. After verification, most cases are caused by users keeping data while reinstalling and switching to a Windows system with another template. Since the database is installed on the D drive, some templates do not have the sqlserver database installed. Before reinstallation, the D drive did not have data corresponding to the sqlserver version, and when keeping data during reinstallation, the data on the D drive will not be replaced, so the database cannot start.
The following is the solution
Before handling, please note the following:
1. If [D:\Program Files\] originally has a Microsoft SQL Server directory, please rename the directory first. The Microsoft SQL Server under [D:\Program Files (x86)\] also needs to be renamed.
2. If the D drive has an mssql directory, please make a copy to keep, and then clear the files in D:\mssql.
I. windows2008+sql2008 cannot start:
Manual download:
http://download.myhostadmin.net/数据库软件/sqlserver2008/2008-d/Program%20Files%20(x86).rar
http://download.myhostadmin.net/数据库软件/sqlserver2008/2008-d/Program%20Files.rar
Download the compressed package and save it to the D drive, right-click -- select Extract to current folder

After extraction is complete, enter the following commands in the cmd command line respectively to reset permissions
cacls "D:\Program Files\Microsoft SQL Server" /e /g mssqluser:f /T
cacls "D:\Program Files (x86)\Microsoft SQL Server" /e /g mssqluser:f /T
cacls D:\mssql /e /g mssqluser:f /T
Finally, enter net start MSSQLSERVER to start the sqlserver database service.
Note: Some newly installed servers may use the westmssql account, so in the above commands, replace mssqluser with westmssql.
II. windows2012+sql2012 cannot start:
Manual download
http://download.myhostadmin.net/数据库软件/sqlserver2012/2012-d/Program%20Files%20(x86).rar
http://download.myhostadmin.net/数据库软件/sqlserver2012/2012-d/Program%20Files.rar
http://download.myhostadmin.net/数据库软件/sqlserver2012/2012-d/mssql.rar
Save it to the D drive, right-click -- select Extract to current folder

Execute the following commands in the command line:
cacls "D:\Program Files\Microsoft SQL Server" /e /g westmssql:f /T
cacls "D:\Program Files (x86)\Microsoft SQL Server" /e /g westmssql:f /T
cacls D:\mssql /e /g westmssql:f /T
Then execute net start MSSQLSERVER to start it

