CREATE FILE encountered operating system error 5 (Access is denied.)

Source: Internet
Author: User
Tags mssqlserver

This post mainly demonstrates "CREATE FILE encountered operating system error 5 (Access is denied.)" The cause of the error (which is, of course, a scenario that causes the error to occur) and how to solve the problem and some puzzling confusion.

Lab Environment:

Operating system version: Windows Server SP2

Version of database: Microsoft SQL Server 2014-12.0.2000.8

As shown below, the SQL Server database services startup account is NT Service\mssqlserver, we first set the default path for the database to E:\SQL_DATA

View the permissions for the E:\SQL_DATA directory at this time (a domain account is blocked). At this point we create the database test with no problem at all. Let's delete the database test first.

Now we delete the user gettestnt55\users this account, in the directory E:\SQL_DATA (properties), Security (edit), the direct deletion will encounter the following error.

We removed this user from the root directory of the E-disk, right-click Properties, and then I created a new database when I encountered the Create FILE encountered operating system error 5 (Access is denied.) Error.

So how to solve it? We can add the virtual account NT Service\mssqlserver to the current directory and grant the relevant permissions to resolve this issue. Refer to the MSDN documentation for details, as shown in the section below

  1. using Windows Explorer, navigate to the file system location where the database files are stored. Right-click the file system folder, and then click .

  2. "security" tab, click "edit" , and then click "add" .

  3. OK . "Data-guid=" 51482BABDB36A64F56FF605D2210C7FB "> "Select Users, Computers, Service Account or Group dialog box, click , At the top of the location list, select your computer name, and then click .

  4. " Enter the name of the object to select box, type the Books Online topic "Configure Windows service accounts and permissions" The name of each service SID listed in the .     nt Service\mssqlserver   for the default instance, or   nt service\mssql$instancename   is used to name the instance. )

  5. Click Check Names to verify the entry. validation often fails, and may tell you that the name cannot be found. click "OK" , the " Found multiple names dialog box is displayed.

  6. < Span id= "mt20" class= "sentence" style= "font-family:; line-height:18px "xml:space=" preserve "data-source=" now select the Per-service SID, either MSSQLSERVER or NT service\mssql$instancename , and then click OK . "Data-guid=" 39E2D39358C86A1C4E4ED1E16019CF5C "> Now select each service SID ( mssqlserver &NBSP; or &NBSP; nt service\ Mssql$instancename ), and then click "OK" .

  7. click " Determine " to return Permissions" dialog box.

  8. < Span id= "mt22" class= "sentence" style= "font-family:; line-height:18px "xml:space=" preserve "data-source=" in the Group or user names box, select the Per-servi Ce SID, and then in the Permissions for &lt;name&gt; box, select the Allow check box for Full Control . "Data-guid=" d4ac29f5cad422982f8ba41b5e6a739a "> in "group or user" name box, select each service SID, and then in " < name > Permissions box, for "Full Control" selected "Allow" check box.

  9. Click Apply, and then click OK two times to exit.

The specific procedure is as follows:

Permission, you need at least "read & Execute", "List Folder Content", "read", "write" permission, of course, if you can give "full Control" permission that is certainly OK. Permission we should try to control the minimum range.

The error can be resolved at this point, when you delete the user and then add the Everyone user to this directory, and the permissions granted above will also resolve the error. Of course the security is better than to give the virtual account NT Service\mssqlserver account authorization.

Certainly there are careful people who will ask, we do not add virtual account NT Service\mssqlserver or everyone, we re-add this user gettestnt55\users, grant the same permissions can solve this problem? The answer is to still encounter this error, why? For the moment I do not understand the specific reasons, is not a bit ironic, know how to solve, but still not clear the specific reasons. Of course, the question of permissions is a bit complicated. If you know the specific reason, please do not hesitate to enlighten me.

References:

Http://www.guyellisrocks.com/2010/07/create-file-encountered-operating.html

http://stackoverflow.com/questions/11178536/ Create-file-encountered-operating-system-error-5failed-to-retrieve-text-for-thi

Https://msdn.microsoft.com/zh-cn/library/jj219062.aspx

CREATE FILE encountered operating system error 5 (Access is denied.)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.