Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

When I am trying to move msdb database from it's default location (C:\Program Files\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\DATA) to another drive(E:). After moving the database I am getting error as shown below.(the error I am getting while expanding database node in SSMS and now I am not able to access any database.)

Failed to retrieve data for this request. (Microsoft.SqlServer.Management.Sdk.Sfc)

For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&LinkId=20476

------------------------------ ADDITIONAL INFORMATION:

An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)


Database 'msdb' cannot be opened due to inaccessible files or insufficient memory or disk space. See the SQL Server errorlog for details. (Microsoft SQL Server, Error: 945)

For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=10.00.2531&EvtSrc=MSSQLServer&EvtID=945&LinkId=20476


The procedure I followed to shift msdb database is as follows:

  1. For each file to be moved, run the following statement.

ALTER DATABASE msdb MODIFY FILE ( NAME = MSDBData , FILENAME = 'E:\MSDBData.mdf' )

ALTER DATABASE msdb MODIFY FILE ( NAME = MSDBLog , FILENAME = 'E:\MSDBLog.ldf' )

  1. Stop the instance of SQL Server to perform maintenance.
  2. Move the file or files to the new location.
  3. Restart the instance of SQL Server or the server. Also i did confirm the path by running following query

SELECT name, physical_name AS CurrentLocation, state_desc FROM sys.master_files WHERE database_id = DB_ID(N'msdb');

And output was showing current location of both MSDBdata and MSDBLog as E:\

This error happened while I did it for testing server. I want to do it for a production server. So please help me on this error. How exactly to move msdb database?

share|improve this question
    
Does the SQL Server service user have proper permissions on that drive? I remember I had permission problems in the past when moving db files on the root of the drive (IIRC on a Win Server 2008). Try to create a new folder and give your service user full permissions on the folder. –  Marian Apr 6 '13 at 10:32
    
I do have full permission.I also checked the error in windows authentication mode, same error repeated. –  IT researcher Apr 6 '13 at 11:17
    
Not your user. The SQL service has another login, by default, if you haven't configured otherwise. It should look like "LocalSystem", "Network user"..something like that. See in the list of services -> Log on as. –  Marian Apr 6 '13 at 11:24
1  
Does the NT AUTHORITY\NETWORKSERVICE account have NTFS permissions to read/write to the root of the E: drive where your msdb database files are located? –  Brian Bentley Apr 6 '13 at 12:02
1  
Right click the drive -> Properties -> Security -> Edit -> add the Network Service user -> give him full control. By default he hasn't. Or better, just create a specific folder and give him Full Control permissions there. And move the data files in that folder. –  Marian Apr 6 '13 at 12:21
show 4 more comments

1 Answer 1

up vote 1 down vote accepted

In the comments you indicate that your SQL Service is running as the Network Service account.

http://msdn.microsoft.com/en-us/library/windows/desktop/ms684272(v=vs.85).aspx

The NetworkService account is a predefined local account used by the service control manager. This account is not recognized by the security subsystem, so you cannot specify its name in a call to the LookupAccountName function. It has minimum privileges on the local computer and acts as the computer on the network.

This is the default account for installations under Vista and Windows Server 2008. During installation this account was granted Full Control file system permissions to the SQL Server data directory as seen in the File System Permissions Granted to SQL Server Per-service SIDs or Local Windows Groups section of the following article.

http://msdn.microsoft.com/en-us/library/ms143504.aspx#Reviewing_ACLs

Since you have relocated some of your database file the SQL Server service account needs permissions to the new locations. In the comments @Marian provided instructions for granting Network Service the required permissions.

Right click the drive -> Properties -> Security -> Edit -> add the Network Service user -> give him full control. By default he hasn't. Or better, just create a specific folder and give him Full Control permissions there. And move the data files in that folder.

The advice to create a new folder and move the files there is excellent as well.

Any additional services that are running as the Network Service account will aslo have permissions to this folder. Ideally the SQL Services should each have their own separate account.

http://support.microsoft.com/kb/2160720

When choosing service accounts, consider the principle of least privilege. The service account should have exactly the privileges that it needs to do its job and no more privileges. You also need to consider account isolation; the service accounts should not only be different from one another, they should not be used by any other service on the same server. Do not grant additional permissions to the SQL Server service account or the service groups. Permissions will be granted through group membership or granted directly to a service SID, where a service SID is supported. For more details please refer to Books Online Topic Setting Up Windows Service Accounts

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.