Jun 12, 2022 | Email Conversion
How to Open MDF File - A Complete Guide
By Deepak Singh Bisht
MDF is a master database file used by Microsoft SQL Server to store data. It is known as the primary database file, which contains schema and data. MDF stores user data in the form of tables, columns, rows, triggers, functions, indexes, and views in a relational database. In SQL Server, each database has a primary MDF file.
In this post, we learn how to open MDF files. If you have MDF files and are looking for a simple way to open them, then this post will be helpful for you.
Location of the MDF file
Default MDF file location in SQL Server 2019
C:\Program Files\Microsoft SQL Server\MSSQL15.MSSQLSERVER\MSSQL\DATA
Default MDF file location in SQL Server 2017
C:\Program Files\Microsoft SQL Server\MSSQL14.MSSQLSERVER\MSSQL\DATA
Default MDF file location in SQL Server 2016
C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\DATA
Default MDF file location in SQL Server 2014
C:\Program Files\Microsoft SQL Server\MSSQL12.MSSQLSERVER\MSSQL\DATA
Default MDF file location in SQL Server 2012
C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\DATA
Default MDF file location in SQL Server 2008
C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA
How to open MDF files?
To open MDF files, you can use SQL Server (SSMS) and the MDF Viewer tool. Here, we will open MDF with or without SQL Server.
Open MDF file in SQL Server Management Studio
This method is known as Attach. To open the MDF file using SSMS, follow the steps below.
- Open SQL Server Management Studio
- Connect to the SQL Server Instance
- From the Sidebar, right-click on the database and select Attach
- In the Attach Databases window, click on the Add button and navigate to the location of your database
- Click on the database and select the MDF file
- Click on the OK button and click on the OK button to Attach the database
Note: If you are getting Microsoft SQL Server Error: 5120, close SSMS and run it as an administrator. After that, attach the MDF as an administrator.
Open MDF file without SQL Server
Here we are going to use the Free viewer MDF Viewer tool. There are various free MDF viewer tools available. You can choose any software as per your convenience. To open an MDF file without SQL Server, follow the steps below.
- Download and install the MDF Viewer Tool
- Open the tool and click on Open
- Select the MDF file which you want to open and click on the Open button
- Choose Quick Scan and select Auto-detect SQL server file version checkbox
- Click on the OK button to start the Scanning process
- Once done, the software will preview MDF file data
Frequently Asked Questions
What program opens .mdf files?
- Microsoft SQL Server
- Visual Studio
- MDF Viewer Tool
How to open MDF without installing SQL Server?
To open an MDF file without SQL server, you can use a third-party MDF viewer tool. There are various MDF viewer tools available. You can also try the SQL Recovery tool. The free version of the SQL Recovery tool also allows you to view MDF file data.