Tuesday, March 27, 2007

Renaming the Central Admin Content Database

I worry sometimes that I might be just a little too pedantic. I can spend way too long figuring out an ideal naming convention. So you can imagine my distress to discover that MOSS 2007 does not give you the option to name the Central Administration content database.

You are able to specify a name for every other database in your installation except this one. It's pretty upsetting for someone as anal as me. All the other databases have a naming pattern that you could write a song to, but the Central Admin content database uses some horrid GUID for it's name.

I decided that I needed to fix this. There is a good reason for this - your SQL Server might host a few Central Admin content databases from different SharePoint Farms. In which case it would be nice to know which SharePoint farm the database belonged to without having to check a list of GUIDs somewhere.

In theory it's relatively straight forward - here are the steps, taken mainly from Ricky Whitworth's blog entry:
1. From Central Admin, remove the existing content database from the Central Admin Web Application.

WARNING: This will break your Central Administration site until you complete the rest of the steps!

2. Backup the existing Admin content database from SQL
3. Restore the backup to SQL using a name that makes you happy
4. Use the STSADM -AddContentDB to attach your renamed content database into your Central Admin site

It was this final step that caught me out. I kept getting a "Access Denied" message. This is not particularly what you want to see when you have just broken your Central Admin site.

What I discovered is that you need to run this command using the AD account that you specified for connecting to the database during your SharePoint installation. Now normally this account should not be a local administrator on your web front end server. However I also found that the command did not work for me until I made this account a local administrator.

So here are the extra steps I carried out between 3. and 4. above:

1. Grant the account running the Central Admin application pool access to the Local Administrators group on your SharePoint server

2. Use the "runas /user:myDomain\myAccount cmd.exe" command line to launch a command window under the credentials of the Central Admin application pool account.

3. Run the following command in your new command window:
C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN\stsadm.exe" -o addcontentdb -url myCentralAdminSite -databasename myCentralAdministrationContentDatabase

4. Remove the account from the Local Administrators group

Update:Here is a post from Keith Richie on how you can use psconfig.exe to set the database name during your initial installation