How to change the default MSSQL directory for database files?

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\DATAanyway.
How to change the default directory for MS SQL?
How to move SQL databases to other disk drive?
By default, the location for new databases in 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 and mastlog.ldf files from %plesk_dir%\Databases\MSSQL\MSSQLXXX.MSSQLSERVERXXX\MSSQL\DATA to D:\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 an 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 > Advanced > 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;
  • Start MS SQL Server service by right-clicking on the corresponding SQL Server > Start.