MSSQL 2016 Server: All databases marked Recovery Pending state

核能气质少年 提交于 2019-12-20 07:26:06

问题


Tonight I had run into this issue where all my databases on our production server were in a Recovery Pending state after doing a Windows (server 2016) Update, an update to my Redgate SQL Backup software and restarting the server. Looking at the logs I found that all of the databases were not accessible with an "Access denied" error. So I figured it was something to do with the user under which the MSSQLSERVER service was running. So I explicitly set permissions to the data and log folders for that user and restarted SQL Server service and all is fine again.

HOWEVER, this server has been running for a very long time - and I have not seen this kind of issue where suddenly the user doesn't have access to the data and log folders. SOMETHING had to have removed permissions on those folders. In addition, now when I look at the security tab of those folders, I see that the user I'm using to run the MSSQLSERVER is explicitly defined. But on our staging server, which has the exact same configuration, I DO NOT see the user explicitly defined there, yet the server is running along just fine.

SO - To my question. What the heck happened? Any ideas? Should I be worried that the user account running my MSSQLSERVER service is now explicitly defined in the Security tab of my data and log folders?


回答1:


Using the manual method to fix recovery pending status in SQL Server Database, which is following-

Set the database status to the emergency:

ALTER DATABASE [dbname] SET EMERGENCY

Put the database in multi-user mode:

ALTER DATABASE [dbname] SET MULTI_USER

Detach the database:

EXEC sp_detach_db '[dbname]'

Reattach the data file only:

EXEC sp_attach_single_file_db @dbname = '[dbname]', @physname = N'[mdf path]'

You can also get a solution from - https://community.spiceworks.com/how_to/157233-how-to-fix-recovery-pending-state-in-sql-server-database



来源:https://stackoverflow.com/questions/44081205/mssql-2016-server-all-databases-marked-recovery-pending-state

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!