debugsqlMinor
Moving SQL Server Database Files to New Location - Why permission error?
Viewed 0 times
whyerrornewsqlpermissiondatabasefilesmovingserverlocation
Problem
I was trying to move a database (
-
-
-
-
-
When I got to Step4, I got "Access Denied". Unfortunately, my maintenance windows were very short and no time to troubleshoot. So I decided to drop the database and restored it using the
My question is why did I get "Access Denied"? I didn't change MSSQL service account. It's the same account that ran the
.mdf and .ldf files) to a different directory on the same server hosting the SQL server. I followed these steps found in this Q&A:-
ALTER DATABASE MyDB SET SINGLE_USER WITH ROLLBACK IMMEDIATE -
ALTER DATABASE MyDB SET OFFLINE -
ALTER DATABASE MyDB MODIFY FILE (Name = MyDB, Filename = 'N:\DATA\MyDB.MDF')-
ALTER DATABASE MyDB SET ONLINE-
ALTER DATABASE MyDB SET MULTI_USERWhen I got to Step4, I got "Access Denied". Unfortunately, my maintenance windows were very short and no time to troubleshoot. So I decided to drop the database and restored it using the
WITH MOVE clause to place the DB files in the right directory. No issue. My question is why did I get "Access Denied"? I didn't change MSSQL service account. It's the same account that ran the
RESTORE.Solution
The
When you move the files prior to step 4, you must ensure the target directory has the correct permissions for the SQL Serve service account. This document details the requirements.
ALTER DATABASE MyDB MODIFY FILE (Name = MyDB, Filename = 'N:\DATA\MyDB.MDF') statement doesn't actually move the files. It merely moves the definition of where the files reside. You'd need to actually move the files manually before continuuing to step 4.When you move the files prior to step 4, you must ensure the target directory has the correct permissions for the SQL Serve service account. This document details the requirements.
Context
StackExchange Database Administrators Q#254673, answer score: 9
Revisions (0)
No revisions yet.