Fix – Tempdb path was wrongly updated

You have Moved the tempdb to other drive and forgot to add the name of the MDF and LDF at the end of the file path, hence the error Error: 5123, Severity: 16, State: 1. Also, unable to restart the SQL Server. Don’t be panic. We can fix this.

In this example I’m going to move the tempdb without providing the file names of data and log.

Find the location of the tempdb files

1

you can also use

 select name,physical_name From sys.master_files where database_id = 2 

Let’s move the tempdb to new location without providing the name of the files

ALTER DATABASE TEMPDB MODIFY FILE (NAME = 'TEMPDEV',
FILENAME = 'C:\Tempdb\')
ALTER DATABASE TEMPDB MODIFY FILE (NAME = 'TEMPLOG', FILENAME = 'C:\Tempdb\')

2

Check the file name paths

3

You can see that the tempdb files are modified in system catalog. Let’s restart the sql server service for change to be effected.  I have restarted the service and trying to connect to sql server but it fails.

4.PNG

Event viewer shows

Event 5123

FCB::Open failed: Could not open file C:\Tempdb\ for file number 1.  OS error: 3(The system cannot find the path specified.).

CREATE FILE encountered operating system error 3(The system cannot find the path specified.) while attempting to open or create the physical file ‘C:\Tempdb\’.

So now that we can’t get into SQL Server. How do we fix it?

Go to command prompt and change the directory to sql server instance Binn directory, then type sqlsrvr -c -f

In my machine i have used named instance so the command would be

C:\Program Files\Microsoft SQL Server\MSSQL12.SQL2014\MSSQL\Binn>sqlservr -sSQL2014 -c -f

5.PNG

Now the SQL Server instance is running in single user mode. You can connect to SQL Server.

6.PNG

There you go! you have connected to the instance. Check the path of the tempdb by running the below T-SQL

select name,physical_name From sys.master_files
where database_id = 2;go

7.PNG

You can see in the above screenshot that the physical name was not correctly given. It shows C:\Tempdb. Let us modify the physical path.

ALTER DATABASE tempdb MODIFY FILE (NAME = 'tempdev', FILENAME = 'c:\tempdb\tempdb.mdf')
ALTER DATABASE tempdb MODIFY FILE (NAME = 'templog', FILENAME = 'c:\tempdb\tempdb.ldf')

8.PNG

Here you go! Correct tempdb path.

Once tempdb has been correctly configured , you can close the SQL Server Instance running in the command prompts by pressing Ctrl+C with the window active. Then restart the SQL Service from the sql server configuration manager.

I have restarted the sql server and open the sql server instance normally. There you go! You have fixed the problem.

9.PNG

Note: I have used different parameters

-c : Start as a console application, not as a service.

-m: Start the SQL service in single user mode

-f : Start the SQL service in Minimal configuration mode.

-s : Connect to named instance of sql server

Cheers

Hope you enjoyed the post!

Ramasankar Molleti

LinkedIn: LinkedIn Profile

Twitter: Twitter

Published by Ramasankar

Hi. I’m Ramasankar Molleti. I’m a passionate IT professional with over 14 years of experience on providing solutions for customers who are looking on cloud computing, Database Migration, Development, and Big Data. I love learning new technologies and share my knowledge to community. I am currently working as Sr Cloud Architect with focus on Cloud Infrastructure, Big Data. I work with developers to architect, build, and manage cloud infrastructure, and services. I have deeep knowledge and experience on working with various database platforms such as MS SQL Server, PostgeSQL, Oracle, MongoDB, Redshift, Dyanamodb, Amazon Aurora. I worked as Database Engineer, Database Administrator, BI Developer and successfully transit myself into Cloud Architect with focus on Cloud infranstructure and Big Data. I live in USA and put my thoughts down on this blog. If you want to get in touch with me, contact me on my Linkedin here: https://www.linkedin.com/in/ramasankar-molleti-23b13218/ My Certifications: Amazon: AWS Certified Solutions Architect – Professional AWS Certified DevOps Engineer – Professional certificate AWS Certified Big Data – Specialty AWS Certified Security – Specialty certificate AWS Certified Advanced Networking – Specialty certificate AWS Certified Solutions Architect – Associate Microsoft: Microsoft® Certified Solutions Associate: SQL Server 2012/2014 Microsoft Certified Professional Microsoft® Certified IT Professional: Database Administrator 2008 Microsoft® Certified Technology Specialist: SQL Server 2008, Implementation and Maintenance

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 )

Google photo

You are commenting using your Google 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 )

Connecting to %s

%d bloggers like this: