CREATE FILE encountered operating system error 5(failed to retrieve text for this error. Reason: 15105)

create file encountered operating system error 32
unable to open the physical file operating system error 5: 5(access is denied)
create database failed. some file names listed could not be created. check related errors.
directory lookup for the file failed with the operating system error 5(access is denied)
create database failed access denied
the operating system returned the error '5(access is denied)
msg 1802, level 16, state 4, line 1
microsoft sql server error 5171

I have a database file .mdf from MS SQL EXPRESS in folder:

C:\Program Files\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\DATA

I would like to attach it to MS 2008 R2 (MSSQL10_50.MSSQLSERVER) but using Server Management Studio I receive the following error:

CREATE FILE encountered operating system error 5(failed to retrieve text for this error. Reason: 15105) while attempting to open or create the physical file

Do you have any idea how to solve it?

I was able to solve the problem running MS SQL Management Studio as ADMINISTRATOR.

FIX: CREATE FILE Encountered Operating System Error 5 (Access , 2018-08-25 22:49:04.33 spid6s FCB::Open failed: Could not open file T:\​TEMPDATA\tempdb.mdf for file number 1. OS error: 2(The system cannot  Operating System Error 5 (failed to retrieve text for this error. Reason: 15105). (Microsoft.SQLServer.Smo) The error may vary, you may also receive Operating system error 5 (Access denied) and that too for local disk instead of network disk.

It's a Windows permissions issue. If you connected to your server using Windows Authentication then that Windows user needs permissions to the file. If you connected to your server using SQL Server authentication then the SQL Server instance account (MSSQL$, e.g. MSSQL$SQLEXPRESS) needs permissions to the file. The other solutions suggesting logging in as an administrator essentially accomplish the same thing (with a bit of a sledgehammer :).

If the database file is in your SQL Server's data folder then it should have inherited the user rights for the SQL Server account from that folder so the SQL Server authentication should have worked. I would recommend fixing the SQL Server instance's account's rights for that folder. If the data file is somewhere else and the SQL Server account does not have permissions then you will likely encounter other problems later. Again, the better solution is to fix the SS account rights. Unless you are always going to log in as administrator...

SQL SERVER, He faced error related to create file in OS. Here is the text of the message. in above error message “operating system error 5(Access is denied.)”. SQL SERVER - Unable to Start SQL Service - OS Error 5 (Access is denied.)  While backup SQL Server database on shared disk within network if the backup file (.bak) denies access, it implies that SQL Server error 15105 has occurred. The corresponding error seems similar to this: "Cannot open backup device "\\xxxxxxxx\xxxx.bak". Operating System Error 5 (failed to retrieve text for this error.

Right Click on File mdf and ldf properties -> security ->full permission

CREATE FILE encountered operating system error 5 (Access is , You are getting a permissions error. The account which is running the SQL Server doesn't have the needed rights on the folder which will  From a OS command prompt, type: net helpmsg 5. You get "Access is denied.". So, it seems like the service account for SQL Server doesn't have permissions on where you try to produce the backup file.

Giving admin rights or full control to my database install location solved my problem

Failed to create a database with error CREATE FILE encountered , I failed to create a database with this message :"SQL server message 5123 : CREATE FILE encountered operating system error 5(failed to retrieve text for Reason: 15105) while attempting to open or create the physical file". Reason: 15105) while attempting to open or create the physical file I used the following command to attach the database: EXEC sp_attach_single_file_db @dbname = 'SPDB', @physname = 'D:\SPDB.mdf'

I had the same problem. After several tries, I realized that connecting the sql server with windows authentication resolved the issue.

CREATE FILE encountered operating system, while attempting to open or create the physical file 'F:\Program "CREATE FILE encountered operating system error 5(Access is denied.) Autodesk Data Management Server Console, the following error message appeared. Get answers fast from Autodesk support staff and product experts in the forums. The OBM will read out the database and compares it with a previous backup, and (if there are differences) will create a incremental of differential file. The full database or the differences will be uploaded to the backup server.

"CREATE FILE encountered operating system error 5(Access is , Fix Microsoft SQL Server restore database error 15105 with different methods and if the backup file (.bak) denies access, it implies that SQL Server error 15105 has occurred. Operating System Error 5 (failed to retrieve text for this error. Sometimes the error message fluctuating on machine may vary and appears while  In MS SQL Server, Error 15105 occurs when the user is trying to create a database backup (.bak) file with the network shared disk. Mostly, the error message 15105 displayed like this: Operating System Error 5: “5 (failed to retrieve the text. Reason: 15105)”.

SQL Backup Error 15105, CREATE FILE encountered operating system error 5(failed to retrieve text for this Right-click on the file which is mentioned in the error message and go to  MS SQL error 15105 is an error message which occur when a user try to create database file backup to a network shared disk or when hosting database file on a network

CREATE FILE Encountered Operating System Error 5 , CREATE FILE encountered operating system error 5(failed to retrieve text for this error. Reason: 15105) while attempting to open or create the physical file  Priyanka is a technology expert working for key technology domains that revolve around Data Recovery and related software's. She got expertise on related subjects like SQL Database, Access Database, QuickBooks, and Microsoft Excel.

Comments
  • Is it possible the mdf is already attached to an instance of SQL Server, or it is open in a Visual Studio project or something along those lines? Have you tried making a copy of the file and attaching that? Where did the MDF file come from? Is it possible it wasn't detached cleanly from its original source?
  • Is SQL Server running as administrator? See CREATE FILE encountered operating system error 5 Access is denied
  • Thanks guys for your comments, I was able to solve the issue running as ADMINISTRATOR thanks!
  • The response by stackoverflow.com/users/2029904/user2029904 is much less aggressive and resolves the underlying problem - insufficient access by the instance account to the database file.
  • @GibboK what if database create with EF:Code First? i change my model and when i try to run program this error apear.i run VS as administrator but nothing change
  • Fixing "insufficient access by the instance account to the database file" didn't work for me, only running as Administrator worked. Why doesn't one Microsoft programmer fix this once and save us all this unnecessary pain?
  • This was my solution. Thanks!
  • Edit the Security properties for the data folder to include full control for the user running SQL Management Studio.
  • The instance account attempts to open the data and log files with a Write DAC permission. This is available if the <Machine>\Users account has full permission to the files. When the Test connection succeeds, these permissions are overwritten to specific SQL Server values, erasing the temporary settings.
  • Run As Administrator does not work for me. When I check, SQL Server in services, it was running under Network Service account. I give Network Service rights on that folder, and create database is a success :)
  • This answer directed me to my solution: Make sure the identity that SQL Server Service is running with (like, "NT Service\MSSQLSERVER"), has access to the DATA folder.
  • This resolved the issue for me. Running SQL Server Management Studio as administrator did not solve it for me.