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

7 comments:

h0tspur said...

thanks for this howto. very good :)

Danny said...

Hmmm... Done exactly what it said on the tin only to find out that after I deleted the original DB name from the central admin content DB list that I still got the "access denied" message and have been unable to access my central admin site since.

What I found was that after I had added the new DB name to the Content DB list it showed "0 sites" next to the new DB I had added. The original conent DB was showing "1 site", but I hoped that once this had been deleted and the site restarted it would have updated to point to the new one.

After removing and restarting I could not access the Central Admin site and nor could I add the original one back in using these instructions as everything I tried gave me an "Access Denied"

Please Help.....

Bert said...

Hi Ivan,
Many thanks for the information. I used it to create my own CLI version:

"stsadm.exe -o deletecontentdb -url http://moss:8000 -databasename SharePoint_AdminContent_a77eb1e6-b914-4f1e-a550-2aab9c61b230 -databaseserver MOSS"

sqlcmd -q "sp_renamedb N'SharePoint_AdminContent_a77eb1e6-b914-4f1e-a550-2aab9c61b230', N'SharePoint_AdminContent_MOSS'"

"stsadm.exe -o addcontentdb -url http://moss:8000 -databasename SharePoint_AdminContent_MOSS -databaseserver MOSS"

The whole story is on http://bevl.blogspot.com/

Regards,
Bert

@danny: when you use the runas command, and you've never logged in interactively whith your service account, try using the /noprofile switch with runas. Worked for me.

Anonymous said...

thx Bert
The /noprofile switch was my saviour

Anonymous said...

Hi,

i have moved the content DB from C: to D: drive.

Afterthat i can able to open all my sites except Central Admin site.

When i try to open Central Admin , its showing "Page cannot be found" 404 error.

In event viewer i got 3760 error "SQL Database '%1' on SQL Server instance '%2' not found."

Have checked my AutoClose option also it's false.

Please Help

Anonymous said...

Thank you so much for the tip about making the database account a local admin. I was going nuts with "Access Denied" errors until I came across your post.

Peace,
Charlie

Johan said...

Thank you for this information. Much appreciated.