Question
The default directory for storing database files of MS SQL is changed in SQL Management Studio > Database Settings > Database default locations to
.
D:MSSQLDATA
However, new database files are being created and stored in
anyway.
%plesk_dir%DatabasesMSSQLMSSQLXXX.MSSQLSERVERMSSQLDATA
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.
https://youtu.be/MqP5BR9fyBo
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
database file, this database is to be moved to the desired path (e.g,
master.mdf
) and SQL server is to be reconfigured accordingly:
D:MSSQLDATA
- 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
and
master.mdf
files from
mastlog.ldf
to
%plesk_dir%DatabasesMSSQLMSSQLXXX.MSSQLSERVERXXXMSSQLDATA
.
D:MSSQLDATANote: 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 ServiceMSSQL$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:MSSQLDATAmaster.mdf;
-eC:Program Files (x86)ParallelsPleskDatabasesMSSQLMSSQLXXX.MSSQLSERVERXXXMSSQLLogERRORLOG;
-lD:MSSQLDATAmastlog.ldf - Start MS SQL Server service by right-clicking on the corresponding SQL Server > Start.