Microsoft MVP성태의 닷넷 이야기
글쓴 사람
정성태 (techsharer at outlook.com)
홈페이지
첨부 파일
 

SSMS - mdf 파일을 Attach 시킬 때 Operating system error 5: "5(Access is denied.)" 에러

예를 들어, mdf/ldf 파일에 대해 "Microsoft SQL Server Management Studio" 도구로 "데이터베이스" 항목을 우클릭해 "연결(Attach)..." 메뉴를 선택, "데이터베이스 연결(Attach Databases)" 창에서 mdf 파일을 선택 후 "확인" 버튼을 눌렀을 때 다음과 같은 오류 창이 나타날 수 있습니다.

ssms_db_attach_1.png

데이터베이스를 연결하는 동안 오류가 발생했습니다. 자세한 내용을 보려면 메시지 열의 하이퍼링크를 클릭하십시오.

An error occurred when attaching the database(s).  Click the hyperlink in the Message column for details.

일단 "확인(OK)" 버튼을 누른 후, "연결할 데이터베이스(Databases to attch)" 리스트 박스의 칼럼 중 "메시지(Message)"를 보면 링크가 있을 텐데,

ssms_db_attach_2.png

그걸 누르면 다음과 같은 메시지를 볼 수 있습니다.

서버 'TESTPC\SQLEXPRESS'에 대한 데이터베이스 연결이(가) 실패했습니다.  (Microsoft.SqlServer.Smo)

...[생략]...

Transact-SQL 문 또는 일괄 처리를 실행하는 동안 예외가 발생했습니다. (Microsoft.SqlServer.ConnectionInfo)

물리적 파일 "D:\db\TestDB.mdf"을(를) 열 수 없습니다. 운영 체제 오류 5: "5(액세스가 거부되었습니다.)".
CREATE DATABASE가 실패했습니다. 나열된 일부 파일 이름을 만들 수 없습니다. 관련 오류를 확인하십시오. (Microsoft SQL Server, 오류: 5120)

Attach database failed for Server 'TESTPC\SQLEXPRESS'.  (Microsoft.SqlServer.Smo)

...[생략]...

An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)

Unable to open the physical file "C:\temp\TestDB.mdf". Operating system error 5: "5(Access is denied.)".
CREATE DATABASE failed. Some file names listed could not be created. Check related errors. (Microsoft SQL Server, Error: 5120)

주요 원인은 "Access is denied"인데요, 즉, mdf 파일을 접근하는데 실패했다는 것입니다. 해결 방법은 간단하겠죠? ^^ "Microsoft SQL Server Management Studio" 응용 프로그램을 관리자 권한으로 실행시키면 됩니다. ^^

주의할 것은, 이때 "관리자 권한"과 함께 SQL 로그인 인증을 반드시 "Windows 인증"으로 해야 합니다. 만약 "SQL Server 인증"으로 로그인하면 여전히 Access is denied 오류가 발생합니다. 부득이 "SQL Server 인증"으로 해야 한다면, mdf와 ldf 파일에 대해 보안 설정으로 들어가,

ssms_db_attach_3.png

위와 같이 "NT Service\MSSQL$SQLEXPRESS" 계정을 Full Control 권한으로 추가해 주면 됩니다.




[이 글에 대해서 여러분들과 의견을 공유하고 싶습니다. 틀리거나 미흡한 부분 또는 의문 사항이 있으시면 언제든 댓글 남겨주십시오.]







[최초 등록일: ]
[최종 수정일: 2/27/2023]

Creative Commons License
이 저작물은 크리에이티브 커먼즈 코리아 저작자표시-비영리-변경금지 2.0 대한민국 라이센스에 따라 이용하실 수 있습니다.
by SeongTae Jeong, mailto:techsharer at outlook.com

비밀번호

댓글 작성자
 




... 121  122  123  124  125  126  127  128  129  [130]  131  132  133  134  135  ...
NoWriterDateCnt.TitleFile(s)
1806정성태11/10/201425138.NET Framework: 477. SeCreateGlobalPrivilege 특권과 WCF NamedPipe
1805정성태11/5/201422004.NET Framework: 476. Visual Studio에서 Mono용 Profiler 개발 [3]파일 다운로드1
1804정성태11/5/201428262.NET Framework: 475. ETW(Event Tracing for Windows)를 C#에서 사용하는 방법 [9]파일 다운로드1
1803정성태11/4/201420357오류 유형: 261. Windows Server Backup 오류 - Error in backup of E:\$Extend\$RmMetadata\$TxfLog
1802정성태11/4/201422292오류 유형: 260. 이벤트 로그 - Windows Error Reporting / AEAPPINVW8
1801정성태11/4/201427613오류 유형: 259. 이벤트 로그 - Windows Error Reporting / IPX Assertion / KorIME.exe [1]
1800정성태11/4/201418275오류 유형: 258. 이벤트 로그 - Starting a SMART disk polling operation in Automatic mode.
1799정성태11/4/201423071오류 유형: 257. 이벤트 로그 - The WMI Performance Adapter service entered the stopped state.
1798정성태11/4/201431865오류 유형: 256. 이벤트 로그 - The WinHTTP Web Proxy Auto-Discovery Service service entered the stopped state. [1]
1797정성태11/4/201417588오류 유형: 255. 이벤트 로그 - The Adobe Flash Player Update Service service entered the stopped state.
1796정성태10/30/201424551개발 환경 구성: 249. Visual Studio 2013에서 Mono 컴파일하는 방법
1795정성태10/29/201427094개발 환경 구성: 248. Lync 2013 서버 설치 방법
1794정성태10/29/201422503개발 환경 구성: 247. "Microsoft Office 365 Enterprise E3" 서비스에 대한 간략 소개
1793정성태10/27/201423165.NET Framework: 474. C# - chromiumembedded 사용 - 두 번째 이야기 [2]파일 다운로드1
1792정성태10/27/201423287.NET Framework: 473. WebClient 객체에 쿠키(Cookie)를 사용하는 방법
1791정성태10/22/201423012VC++: 83. G++ - 템플릿 클래스의 iterator 코드 사용에서 발생하는 컴파일 오류 [5]
1790정성태10/22/201418539오류 유형: 254. NETLOGON Service is paused on [... AD Server...]
1789정성태10/22/201421215오류 유형: 253. 이벤트 로그 - The client-side extension could not remove user policy settings for '...'
1788정성태10/22/201423239VC++: 82. COM 프로그래밍에서 HRESULT 타입의 S_FALSE는 실패일까요? 성공일까요? [2]
1787정성태10/22/201431408오류 유형: 252. COM 개체 등록시 0x8002801C 오류가 발생한다면?
1786정성태10/22/201432739디버깅 기술: 65. 프로세스 비정상 종료 시 "Debug Diagnostic Tool"를 이용해 덤프를 남기는 방법 [3]파일 다운로드1
1785정성태10/22/201421945오류 유형: 251. 이벤트 로그 - Load control template file /_controltemplates/TaxonomyPicker.ascx failed [1]
1784정성태10/22/201430032.NET Framework: 472. C/C++과 C# 사이의 메모리 할당/해제 방법파일 다운로드1
1783정성태10/21/201423497VC++: 81. 프로그래밍에서 borrowing의 개념
1782정성태10/21/201420221오류 유형: 250. 이벤트 로그 - Application Server job failed for service instance Microsoft.Office.Server.Search.Administration.SearchServiceInstance
1781정성태10/21/201420686디버깅 기술: 64. new/delete의 짝이 맞는 경우에도 메모리 누수가 발생한다면?
... 121  122  123  124  125  126  127  128  129  [130]  131  132  133  134  135  ...