Applicable to:
- Plesk for Windows
Question
The default directory for storing database files of MS SQL is changed in SQL Management Studio > Database Settings > Database default locations to
D:\MSSQL\DATA
.
However, new database files are being created and stored in
%plesk_dir%\Databases\MSSQL\MSSQLXXX.MSSQLSERVER\MSSQL\DATA
anyway.
How to change the default directory for MS SQL?
Answer
Note: To apply the solution from this article, it is required to have administrative RDP access to the server. Please contact your hosting provider support or server's administrator if you don't have administrative RDP access or ask them to apply the solution.
Warning: existing databases will continue using the default MSSQL directory and will not respect the changes
By default, the location for new databases in MS SQL is defined by the location of the
master.mdf
database file, this database is to be moved to the desired path (e.g,
D:\MSSQL\DATA
) and SQL server is to be reconfigured accordingly:
- Connect to the server via RDP;
- Open SQL Server Configuration Manager.
- Expand
Services
; - Click
SQL Server
; - In the results pane, right-click the named instance of SQL Server, and then click
Stop
.
A red box on the icon next to the server name and on the toolbar indicates that the server stopped successfully; - Move
master.mdf
andmastlog.ldf
files from%plesk_dir%\Databases\MSSQL\MSSQLXXX.MSSQLSERVERXXX\MSSQL\DATA
toD:\MSSQL\DATA
.Note: XXX should be replaced by the actual path, it depends on the version of the MS SQL server;
- Set
Full Control
permissions for the MS SQL service account, for example NT Service\MSSQL$MSSQLSERVERXXXX, to the new DATA directory. Detailed steps are described here. - In SQL Server Configuration Manager > right-click SQL Server > Properties > Startup Parameters specify new paths for the master database:
-dD:\MSSQL\DATA\master.mdf;
-eC:\Program Files (x86)\Parallels\Plesk\Databases\MSSQL\MSSQLXXX.MSSQLSERVERXXX\MSSQL\Log\ERRORLOG;
-lD:\MSSQL\DATA\mastlog.ldf - Start MS SQL Server service by right-clicking on the corresponding SQL Server > Start.
Comments
0 comments
Please sign in to leave a comment.