Hi All,
Current environment: Microsoft SQL Server 2017 (RTM-CU23) (KB5000685) - 14.0.3381.3 (X64) Feb 9 2021 12:08:50 Copyright (C) 2017 Microsoft Corporation Enterprise Edition (64-bit) on Windows Server 2016 Standard 10.0 <X64> (Build 14393: ) (Hypervisor)
I am currently running SQL Server in a Failover Cluster, and we are in the process of migrating our data storage to a new array. I have to modify file_name from old location (J:\ drive) to the new location (K:\ drive).
The steps I am using are as follows:
- ALTER DATABASE xxx SET OFFLINE;
- Go to OS and FILE COPY the .mdf to the new location on the K:\NEWDIR\xxx_db.mdf
- Go to OS and FILE COPY the .ldf to the new location on the L:\NEWDIR]xxx_log.ldf
- ALTER DATABASE xxx MODIFY FILE (name ='xxx_db', filename = 'K:\NEWDIR\xxx_db.mdf' );
- ALTER DATABASE xxx MODIFY FILE (name ='xxx_log', filename = 'L:\NEWDIR\xxx_log.ldf' );
- ALTER DATABASE xxx SET ONLINE;
The ALTER DATABASE xxx SET ONLINE; caused the error:
Msg 5120, Level 16, State 101, Line 10
Unable to open the physical file "K:\NEWDIR\xxx_db.mdf". Operating system error 5: "5(Access is denied.)".
So I resolved the error, going into file permissions and granting FULL CONTROL to the SQL Server Service Account. No problem.
My issue? I then compared the permission settings between the OLD *.mdf and the NEW *.mdf and I saw a difference that I can't figure out how to migrate.
The old *.mdf has FULL CONTROL granted to "MSSQL$<instance_name>". I can't figure out how to migrate that permission to the new *.mdf. I am unable to match the permissions "MSSQL$<instance_name>" that the old .mdf (and .ldf) had.
As a final test, I created a new database using SSMS in the new location, and by default, the permission mask was set to "MSSQL$<instance_name>" with FULL CONTROL.
Questions:
- How does SSMS assign the permissions to a newly created database?
- How do I replicate these permissions to a database that I have moved to a new location using the documented migration procedure?
- What am I missing here?
Thank you for your help.
--Dan