I explained in detail how to create a database in the article “How to Create a Database on SQL Server“. If you do not select a path to create database files during the database creation phase, the data and log files will be created on the default paths that were previously set. We set these default paths during SQL Server installation. If you have not changed these paths after the installation, these paths set in the setup phase will be valid. You can reach details in the article “How To Install SQL Server“.
So how do we change this default path, which is the subject of our article. Right-click on Instance and click on Properties and go to Database Settings as follows. Below you will see Data, Log and Backup. You can set default paths here.
When creating a database, the database data files are automatically created in the default path set for Data unless you specify otherwise.
The log file of the database is also automatically created in the default path set for Log unless you specify otherwise.
When you take a backup, the backup path information is automatically selected from the Default Backup Path. You can change this path when you are backing up.
After making changes, right click on the instance and click Properties. When you get to the Database Settings section, you will see that the default path set for Backup has changed and the paths you set for the Data and Log file have not changed. These changes actually happened, but the service needs to be restarted. If you check again after restarting the service, you will see the changes being performed.
You can perform SQL Server Service Restart through SQL Server Configuration Manager by right-clicking on the services that appear on the right in the following screenshot. You can learn more about SQL Server Configuration Manager in the article “SQL Server Configuration Manager Settings”