SQL SERVER – Error : Fix : Msg 5133, Level 16, State 1, Line 2 Directory lookup for the file failed with the operating system error 2(The system cannot find the file specified.)

I recently got email from friend who had suffered from following error.

Msg 5133, Level 16, State 1, Line 2
Directory lookup for the file “filepath” failed with the operating system error 2(The system cannot find the file specified.).
Msg 1802, Level 16, State 1, Line 2
CREATE DATABASE failed. Some file names listed could not be created. Check related errors.
Msg 5133, Level 16, State 1, Line 2
Directory lookup for the file “filepath” failed with the operating system error 2(The system cannot find the file specified.).
Msg 1802, Level 16, State 1, Line 2
CREATE DATABASE failed. Some file names listed could not be created. Check related errors.

As per him he had gone crazy to find solution. He had been trying to create database  and he had all the admin privileges. After getting remote desktop, I realize that he was everything correct but the filepath he was trying to create. Once he corrected the filepath everything was smooth from there.

If you have the same error I suggest you carefully check your filepath. There must be some typo or error in filepath. If that is not the case and with admin rights you are still facing issue, post a comment here.

Reference: Pinal Dave (http://blog.SQLAuthority.com)

About these ads

23 thoughts on “SQL SERVER – Error : Fix : Msg 5133, Level 16, State 1, Line 2 Directory lookup for the file failed with the operating system error 2(The system cannot find the file specified.)

  1. I already get this error and the paths were right. I was trying to create database in a path like this: C:\programs\MyProgram\MyProgram.mdb and what solves my problem was runnig sql server not by local account but by using a computer account. Is this the macthing of the admin privileges??
    Reagards.

  2. verify that you created the folders in the path
    verify that your session runs by windows authentication or damain account that had permission on created Folders

  3. Msg 5133, Level 16, State 1, Line 2
    Directory lookup for the file “filepath” failed with the operating system error 2(The system cannot find the file specified.).
    am getting the same error msg ihave tried to run in Admin mode also, i have check my file path everything is good, But still am getting this error. can you tell me why?

  4. FIX: I was importing a .BAK file from Microsoft SQL Server Management Studio Express and kept getting the error: Directory lookup for the file “C:\\MSSQLDB\\mydatabase.mdf” failed with the operating system error 2.

    This was regardless of the fact that I was importing the .BAK file from a completely different location!

    After not having any luck with more logical solutions…I tried creating a \”C:\\MSSQLDB\” folder and moving my BAK file into that folder. (folder didn\’t exist before)

    This ended up working and my database imported successfully.

  5. Msg 5133, Level 16, State 1, Line 2
    Directory lookup for the file “E:\db_SqlDatafiles\Trustbank_VMUCB_Warora1.ldf” failed with the operating system error 2(The system cannot find the file specified.).
    Msg 3156, Level 16, State 3, Line 2
    File ‘Trustbank_Hinganghat_Branch_log1′ cannot be restored to ‘E:\db_SqlDatafiles\Trustbank_VMUCB_Warora1.ldf’. Use WITH MOVE to identify a valid location for the file.
    Msg 3119, Level 16, State 1, Line 2
    Problems were identified while planning for the RESTORE statement. Previous messages provide details.
    Msg 3013, Level 16, State 1, Line 2
    RESTORE DATABASE is terminating abnormally.

  6. Directory lookup for the file “E:\SQLDATA\DATA\HMS_DB_OOCE.mdf” failed with the operating system error 3(The system cannot find the path specified.).

    I got this error when trying to execute script from one system in another system.

  7. Also, check if you have directly opened the file you have been given ?
    Better idea is to create a ‘New Query’ window on the ‘master’ then copy paste the script and then execute

  8. I got this same problem, but after I manually created the folder structure i specified in the FileName, and then ran the create database script again, it ran successfully without throwing this error.

  9. hello sir i have this error,
    “Msg 5120, Niveau 16, État 101, Ligne 1
    Impossible d’ouvrir le fichier physique “D:\WebSites\VentePC\App_Data\VentePC.mdf”. Erreur du système d’exploitation 5 : “5(Accès refusé.)”.
    I changed the file path but I always have the same error. Please help me.

  10. This site is top notch!

    However, this answer does not (exactly) apply to all situations. I got this error today using a script that does not name a path. It uses the storage location set in the instance preferences.

    This same script has been used many times (100’s) and has been used between these same two servers at least 10+ times.

    One of the other commenters said something about the SQL user, that could be, but why would it change all of a sudden?

    Furthermore, the the source system datastore was on the “D:” drive the target system has no “D:” drive… — but I do see the bad path (“D:…”) in the error, why is this showing up at all, it is a full backup.

  11. im not able to provide the path , i have to copy the path the path and paste it in the file name still i have this error ..the mdf file is in the ‘owner’ folder even after providing full control i am not able to access the files within it..

  12. For me it worked when I set full permissions on Authenticated users. Before that, I wasn’t even able to see folders in the folder structure withing sql server when picking path to DB.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s