성태의 닷넷 이야기
홈 주인
모아 놓은 자료
프로그래밍
질문/답변
사용자 관리
사용자
메뉴
아티클
외부 아티클
유용한 코드
온라인 기능
MathJax 입력기
최근 덧글
[정성태] The Windows Registry Adventure #1: ...
[정성태] systemd for Developers I ; https:/...
[정성태] 엄밀히 object 타입의 인스턴스가 다른 타입으로 형변환 가능...
[정성태] 아래의 글에서 나오는 "Windows Application Pa...
[정성태] The history of calling conventions,...
[정성태] Secure and Deploy .NET Windows Form...
[정성태] Get Started with Milvus Vector DB i...
[정성태] cyberark/PipeViewer - A tool that...
[정성태] WinForms in a 64-Bit world – our st...
[정성태] 예제에서 SELECT_SQL도 내부적으로는 SqlCommand/...
글쓰기
제목
이름
암호
전자우편
HTML
홈페이지
유형
제니퍼 .NET
닷넷
COM 개체 관련
스크립트
VC++
VS.NET IDE
Windows
Team Foundation Server
디버깅 기술
오류 유형
개발 환경 구성
웹
기타
Linux
Java
DDK
Math
Phone
Graphics
사물인터넷
부모글 보이기/감추기
내용
<div style='display: inline'> <h1 style='font-family: Malgun Gothic, Consolas; font-size: 20pt; color: #006699; text-align: center; font-weight: bold'>SQL Express - User Instance 옵션을 사용한 경우 발생하는 오류 메시지 유형 2가지</h1> <p> <br /> 예전에, SQL Express의 "User Instance" 옵션에 대해서 설명해드린 적이 있지요.<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > SQL Express 버전과 User Instance 옵션 ; <a target='tab' href='http://www.sysnet.pe.kr/2/0/668'>http://www.sysnet.pe.kr/2/0/668</a> </pre> <br /> 테스트용의 간단한 웹 사이트와 연동하는 용도로는 딱이어서, 개인적으로도 가끔씩 사용하곤 합니다.<br /> <br /> 그런데, 이와 관련해서 오류를 접하게 되는데 그중에서 2가지 유형 정도만 기록으로 남겨보겠습니다.<br /> <br /> 우선, 권한 관련 오류입니다.<br /> <br /> <br /> <div style='BACKGROUND-COLOR: #ccffcc; padding: 10px 10px 5px 10px; MARGIN: 0px 10px 10px 10px; FONT-FAMILY: Malgun Gothic, Consolas, Verdana; COLOR: #005555'> Server Error in '/' Application.<br /> --------------------------------------------------------------------------------<br /> <br /> Database 'C:\...[생략]...\APP_DATA\ASPNETDB.MDF' cannot be upgraded because it is read-only or has read-only files. Make the database or files writeable, and rerun recovery.<br /> An attempt to attach an auto-named database for file C:\...[생략]...\App_Data\aspnetdb.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share. <br /> Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. <br /> <br /> Exception Details: System.Data.SqlClient.SqlException: <span style='color: blue; font-weight: bold'>Database 'C:\...[생략]...\APP_DATA\ASPNETDB.MDF' cannot be upgraded because it is read-only or has read-only files.</span> Make the database or files writeable, and rerun recovery. An attempt to attach an auto-named database for file C:\...[생략]...\App_Data\aspnetdb.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.<br /> <br /> Source Error: <br /> <br /> An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. <br /> <br /> Stack Trace: <br /> <br /> <br /> [SqlException (0x80131904): Database 'C:\...[생략]...\APP_DATA\ASPNETDB.MDF' cannot be upgraded because it is read-only or has read-only files. Make the database or files writeable, and rerun recovery.<br /> An attempt to attach an auto-named database for file C:\...[생략]...\App_Data\aspnetdb.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.]<br /> System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +308<br /> System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning() +412<br /> ...[생략]...<br /> System.Web.Security.SqlMembershipProvider.ValidateUser(String username, String password) +202<br /> System.Web.UI.WebControls.Login.AuthenticateUsingMembershipProvider(AuthenticateEventArgs e) +234<br /> System.Web.UI.WebControls.Login.AttemptLogin() +166<br /> System.Web.UI.WebControls.Login.OnBubbleEvent(Object source, EventArgs e) +91<br /> System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +52<br /> System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3394<br /> </div><br /> <br /> 이런 오류를 만난 경우, 실제로 해당 mdf/ldf 파일 속성에 '읽기 전용' 속성이 있는지 체크할 필요가 있습니다. (가끔씩 실수로 TFS 소스 컨트롤에 들어가 있는 경우.)<br /> <br /> 그런데, 가끔은 SQL Express 프로세스(sqlservr.exe) 자체가 "User Instance"로 연결할 mdf/ldf 파일에 대한 권한이 없어서 발생하는 경우도 있습니다. 이 문제를 해결하려면, 우선 연결 문자열을 확인해서 SQL Server 인스턴스 명을 확인합니다. (해당 컴퓨터에 SQL 서버 인스턴스가 하나만 설치되어 있다면 확인할 필요가 없습니다.)<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > <connectionStrings> <add name="ApplicationServices" connectionString="data source=<span style='color: blue; font-weight: bold'>.\SQLEXPRESS</span>;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient" /> </connectionStrings> </pre> <br /> 위의 예에서는 ".\SQLEXPRESS"라고 되어 있는데요. 그럼 로컬 컴퓨터의 NT 서비스 관리자에서 "SQL Server (SQLEXPRESS)"라는 이름의 서비스를 찾아서 "Log On" 계정을 알아냅니다. 예를 들어, 그 계정으로 "NETWORK SERVICE"가 할당되어 있다면, ASPNETDB.MDF, aspnetdb_log.ldf 2개의 파일에 대한 속성창에서 아래와 같이 권한을 부여해 주면 됩니다.<br /> <br /> <img alt='access_failure_aspnetdb_1.png' src='/SysWebRes/bbs/access_failure_aspnetdb_1.png' /><br /> <br /> <hr style='width: 50%' /><br /> <br /> 경우에 따라서, 다음과 같은 오류를 접하기도 합니다.<br /> <br /> <div style='BACKGROUND-COLOR: #ccffcc; padding: 10px 10px 5px 10px; MARGIN: 0px 10px 10px 10px; FONT-FAMILY: Malgun Gothic, Consolas, Verdana; COLOR: #005555'> Server Error in '/' Application.<br /> --------------------------------------------------------------------------------<br /> <br /> <span style='color: blue; font-weight: bold'>Failed to generate a user instance of SQL Server due to a failure in starting the process for the user instance. The connection will be closed. </span> Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. <br /> <br /> Exception Details: System.Data.SqlClient.SqlException: Failed to generate a user instance of SQL Server due to a failure in starting the process for the user instance. The connection will be closed.<br /> <br /> Source Error: <br /> <br /> An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. <br /> <br /> Stack Trace: <br /> <br /> <br /> [SqlException (0x80131904): Failed to generate a user instance of SQL Server due to a failure in starting the process for the user instance. The connection will be closed.]<br /> System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +5061898<br /> ...[생략]...<br /> System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5563<br /> </div><br /> <br /> 이 오류에 대해서 검색을 해보면, "User Instance" 옵션을 "False"로 설정해서 해결했다는 식의 다소 황당한 답변이 나오기도 합니다. 제 경우에는 다음의 답변을 보고 해결했습니다.<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > Fix error "Failed to generate a user instance of SQL Server due to a failure in starting the process for the user instance." ; <a target='tab' href='http://www.aspdotnetfaq.com/Faq/fix-error-Failed-to-generate-a-user-instance-of-SQL-Server-due-to-a-failure-in-starting-the-process-for-the-user-instance.aspx'>http://www.aspdotnetfaq.com/Faq/fix-error-Failed-to-generate-a-user-instance-of-SQL-Server-due-to-a-failure-in-starting-the-process-for-the-user-instance.aspx</a> </pre> <br /> 위에서 제시한 경로를 삭제하면 문제가 해결됩니다. 단지, 윈도우 7의 경우 경로가 다소 달라서 헷갈릴 수 있는데요. 일반 계정이라면 다음과 같이 구성되고,<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > %LOCALAPPDATA%\Microsoft\Microsoft SQL Server Data\[SQL 인스턴스 명] </pre> <br /> 그 외, 서비스 계정이라면 다음과 같이 완전히 별개의 폴더에 구성되어 있으니 유의하시면 되겠습니다.<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > [예: "Network Service" 서비스인 경우] C:\Windows\ServiceProfiles\NetworkService\AppData\Local\Microsoft\Microsoft SQL Server Data\[SQL 인스턴스 명] </pre> </p><br /> <br /> <br /><hr /><span style='color: Maroon'>[이 글에 대해서 여러분들과 의견을 공유하고 싶습니다. 틀리거나 미흡한 부분 또는 의문 사항이 있으시면 언제든 댓글 남겨주십시오.]</span> </div>
첨부파일
스팸 방지용 인증 번호
5369
(왼쪽의 숫자를 입력해야 합니다.)