Problem: Error 5123 is displayed when you’re trying to attach a database in SQL Server 2008 R2 that was previously detached by another user with a different login.
CREATE FILE encountered operating system error 5 (Access is denied) while attempting to open or create the physical file… (Microsoft SQL Server, Error 5123)
Solution
Step 1: In the Security tab of the Properties dialog, selected OWNER RIGHTS in the “Group or user names” section, the listed permissions were empty for both Allow and Deny.
Step 2: Click on Advanced and, from that view, OWNER RIGHTS had all permissions checked.
Step 3: Click Edit and ensure that all check boxes are set for Allow.
Reference
Database Attach Failure in SQL Server 2008 R2
SQL SERVER – FIX: Msg 5123, Level 16 – CREATE FILE Encountered Operating System Error 5
How to Fix SQL Server 2008 R2 Database Error 5123
How to Resolve Microsoft SQL Server Error 824 Manually?