SQL SERVER – Unable to Start SQL Service – OS Error 5 (Access is denied.) for TempDB

This was really one of the issue where I was totally confused because SQL Server was raising incorrect error message. Let me first tell you what I was doing. I was trying to move TEMPDB database files to a new location. I ran below alter commands and restarted SQL Server. Let us learn about OS Error 5.

   (NAME = 'tempdev', FILENAME = 'E:\TempDB')

Now, SQL was not getting started so I looked into ERRORLOG and found below the messages. I have trimmed all four 10s (system SPID) which is trying to start up tempdb database.

2017-03-09 09:16:07.84 spid6s Clearing tempdb database.
2017-03-09 09:16:07.84 spid6s Error: 5123, Severity: 16, State: 1.
2017-03-09 09:16:07.84 spid6s CREATE FILE encountered operating system error 5(Access is denied.) while attempting to open or create the physical file ‘E:\TempDB’.
2017-03-09 09:16:07.84 spid6s Error: 17204, Severity: 16, State: 1.
2017-03-09 09:16:07.84 spid6s FCB::Open failed: Could not open file E:\TempDB for file number 1. OS error: 5(Access is denied.).
2017-03-09 09:16:07.84 spid6s Error: 5120, Severity: 16, State: 101.
2017-03-09 09:16:07.84 spid6s Unable to open the physical file “E:\TempDB”. Operating system error 5: “5(Access is denied.)”.
2017-03-09 09:16:07.84 spid6s Error: 1802, Severity: 16, State: 4.
2017-03-09 09:16:07.84 spid6s CREATE DATABASE failed. Some file names listed could not be created. Check related errors.
2017-03-09 09:16:07.84 spid6s Could not create tempdb. You may not have enough disk space available. Free additional disk space by deleting other files on the tempdb drive and then restart SQL Server. Check for additional errors in the event log that may indicate why the tempdb files could not be initialized.
2017-03-09 09:16:07.84 spid6s SQL Server shutdown has been initiated
2017-03-09 09:16:07.84 spid6s SQL Trace was stopped due to server shutdown. Trace ID = ‘1’. This is an informational message only; no user action is required.

From above messages (Access is denied), it looked like permission issue, but I don’t think it was a permission issue as SQL Account was a local administrator on windows. Yeah, I know, I know… not recommended, but who cares when it’s a test VM.

While digging further in ERRORLOG, I realized that there is no reference to MDF and LDF file? Then I looked at my command again and damn…. I missed a file name there and left up to the directory.


As found earlier, it was an incorrect tempdb configuration causing SQL not to start. To fix the configuration, we need to start SQL Service. Catch 22 situation.  Luckily, there are way to start SQL in such situations.  We started SQL Server /f and /m and Altered TempDB to have correct file path and name.

  1. Start SQL with /f and /mSQLCMD (SQL SERVER – The Story of a Lesser Known Startup Parameter in SQL Server – Guest Post by Balmukund Lakhani)
  2. Connect to SQL via SQLCMD.
  3. Run following ALTER command
(NAME = 'tempdev', FILENAME = 'E:\TempDB\TempDB.mdf')
  1. Stop SQL
  2. Start SQL normally.

Here is how the command prompt would look like.

SQL SERVER - Unable to Start SQL Service - OS Error 5 (Access is denied.) for TempDB tempdb-access-denied-02-800x391

Have you ever faced a similar issue? Please comment and let me know.

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

SQL Scripts, SQL Server, SQL TempDB, Starting SQL
Previous Post
SQL SERVER – Mirroring Error: Connection handshake failed. Could not send a handshake message because the connection was closed by peer. State 26
Next Post
SQL SERVER – Installation Wizard Hangs at Service Account Page – The RPC Server is Unavailable

Related Posts

1 Comment. Leave new

  • Thank you very much this solution save my life :)


Leave a Reply