Skip to content

Commit dae6035

Browse files
committed
Refresh default file locations article and include UUF 227571
1 parent ddc5999 commit dae6035

1 file changed

Lines changed: 74 additions & 34 deletions

File tree

Lines changed: 74 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,74 @@
1-
---
2-
title: "View or Change the Default Locations for Data and Log Files"
3-
description: "Find out how to view or change the default locations for SQL Server data files and log files. See how to protect the files with access control lists (ACLs)."
4-
author: rwestMSFT
5-
ms.author: randolphwest
6-
ms.date: "06/13/2017"
7-
ms.service: sql
8-
ms.subservice: configuration
9-
ms.topic: conceptual
10-
helpviewer_keywords:
11-
- "log files [SQL Server], changing default location"
12-
- "data files [SQL Server], changing default location"
13-
---
14-
# View or Change the Default Locations for Data and Log Files
15-
[!INCLUDE [SQL Server](../../includes/applies-to-version/sqlserver.md)]
16-
17-
The best practice for protecting your data files and log files is to ensure that they are protected by access control lists (ACLs). Set the ACLs on the directory root under which the files are created.
18-
19-
20-
## View or change the default locations for database files
21-
22-
1. In Object Explorer, right-click on your server and click **Properties**.
23-
24-
2. In the left panel on that Properties page, click the **Database settings** tab.
25-
26-
3. In **Database default locations**, view the current default locations for new data files and new log files. To change a default location, enter a new default pathname in the **Data** or **Log** field, or click the browse button to find and select a pathname.
27-
28-
> [!NOTE]
29-
> After changing the default locations, you must stop and start the SQL Server service to complete the change.
30-
31-
## See also
32-
[CREATE DATABASE (SQL Server Transact-SQL)](../../t-sql/statements/create-database-transact-sql.md)
33-
[Create a Database](../../relational-databases/databases/create-a-database.md)
34-
1+
---
2+
title: View or change the default locations for data and log files
3+
description: "Find out how to view or change the default locations for SQL Server data files and log files. See how to protect the files with access control lists (ACLs)."
4+
author: rwestMSFT
5+
ms.author: randolphwest
6+
ms.date: 03/22/2024
7+
ms.service: sql
8+
ms.subservice: configuration
9+
ms.topic: conceptual
10+
helpviewer_keywords:
11+
- "log files [SQL Server], changing default location"
12+
- "data files [SQL Server], changing default location"
13+
---
14+
# View or change the default locations for data and log files
15+
16+
[!INCLUDE [sql-windows-only](../../includes/applies-to-version/sql-windows-only.md)]
17+
18+
The best practice for protecting your data files and log files is to ensure that they are protected by access control lists (ACLs). Set the ACLs on the directory root under which the files are created.
19+
20+
> [!NOTE]
21+
> These instructions are for [!INCLUDE [ssnoversion-md](../../includes/ssnoversion-md.md)] on Windows only. To change the default locations for [!INCLUDE [sqlonlinux-md](../../includes/sqlonlinux-md.md)], see [Configure SQL Server on Linux with the mssql-conf tool](../../linux/sql-server-linux-configure-mssql-conf.md).
22+
23+
## Use SQL Server Management Studio
24+
25+
1. In Object Explorer, right-click on your server and select **Properties**.
26+
27+
1. In the left panel on that Properties page, select the **Database settings** tab.
28+
29+
1. In **Database default locations**, view the current default locations for new data files and new log files. To change a default location, enter a new default pathname in the **Data** or **Log** field, or select the browse button to find and select a pathname.
30+
31+
1. After changing the default locations, you must stop and start the [!INCLUDE [ssnoversion-md](../../includes/ssnoversion-md.md)] service to complete the change.
32+
33+
## Use Transact-SQL
34+
35+
> [!CAUTION]
36+
> The following example uses an extended stored procedure to modify the server registry. Serious problems might occur if you modify the registry incorrectly. These problems might require you to reinstall the operating system. Microsoft cannot guarantee that these problems can be resolved. Modify the registry at your own risk.
37+
38+
1. Connect to the [!INCLUDE [ssDE](../../includes/ssde-md.md)].
39+
40+
1. From the Standard bar, select **New Query**.
41+
42+
1. Copy and paste the following example into the query window. Replace the `<path_*>` values with the new locations you wish to place your data and log files, and then select **Execute**.
43+
44+
```sql
45+
USE [master];
46+
GO
47+
EXEC xp_instance_regwrite
48+
N'HKEY_LOCAL_MACHINE', N'Software\Microsoft\MSSQLServer\MSSQLServer',
49+
N'BackupDirectory',
50+
REG_SZ,
51+
N'<path_to_database_backup_files>'
52+
GO
53+
EXEC xp_instance_regwrite
54+
N'HKEY_LOCAL_MACHINE',
55+
N'Software\Microsoft\MSSQLServer\MSSQLServer',
56+
N'DefaultData',
57+
REG_SZ,
58+
N'<path_to_data_files>'
59+
GO
60+
EXEC xp_instance_regwrite
61+
N'HKEY_LOCAL_MACHINE',
62+
N'Software\Microsoft\MSSQLServer\MSSQLServer',
63+
N'DefaultLog',
64+
REG_SZ,
65+
N'<path_to_log_files>'
66+
GO
67+
```
68+
69+
1. After changing the default locations, you must stop and start the [!INCLUDE [ssnoversion-md](../../includes/ssnoversion-md.md)] service to complete the change.
70+
71+
## Related content
72+
73+
- [CREATE DATABASE](../../t-sql/statements/create-database-transact-sql.md)
74+
- [Create a database](../../relational-databases/databases/create-a-database.md)

0 commit comments

Comments
 (0)