How to Rename SharePoint 2013 Central Admin Database to Remove GUID?

When you run the SharePoint products configuration wizard right after installing SharePoint binaries, it creates SharePoint central administration database with GUIDs. E.g. SharePoint_AdminContent_a149fa83-d2b9-4ad9-9e4c-ad12f73f0dd6.

Your DBAs may not be happy with these GUIDs as they deviates from database naming standards. So, lets rename SharePoint Central administration content database with the following steps:
sharepoint admin content database guid
Always, Remember to backup SharePoint Central Admin database prior performing these steps.
Here is how to remove GUID from SharePoint 2013 Central Admin database in three simple steps:

Step 1. Detach Central Admin Content Database:
Detach Central Admin Content Database: (PowerShell: Dismount-SPContentDatabase)

stsadm -o deletecontentdb -url http://centraladmin:2013 -databasename SharePoint_AdminContent_a149fa83-d2b9-4ad9-9e4c-ad12f73f0dd6 -databaseserver SP13_SQL

Step 2. Rename the Content Database from SQL Server
Right click the database, Choose Properties, Select Options tab. Set the Database restricted access property to to "Single User Mode". Rename the Database by removing GUID from it (Right click the database, choose "Rename"). Now, set the database restricted access back to "Multi-User".
sharepoint 2013 database names guid

Step 3.Attach the renamed Content Database
Attach the renamed content database back to Central Administration web application: (PowerShell: Mount-SPContentDatabase)

stsadm -o addcontentdb -url http://centraladmin:2013 -databasename SharePoint_AdminContent 
How to Rename SharePoint 2013 Central Admin Database to Remove GUID?

Alternate approach to rename SharePoint database:

Alternatively, You can create a create a new content database with right naming conventions, Move all sites from the existing content database to new database and then get-rid of the old database. Here is the script:
#Create new Content Database
New-SPContentDatabase -Name SharePoint_AdminContent -WebApplication http://centraladmin:2013
Now the Central Admin should have two databases attached with it.
sharepoint admin content database guid

Lets get the IDs of those two databases:
# Get SharePoint database IDs for old and new DBs for central admin site
Get-SPWebApplication –Identity http://centraladmin:2013 | Get-SPContentDatabase | SELECT ID, Name, WebApplication | Format-List

#Note down the IDs of Original Database and New Database. 
# In my case, Old database id: c87506a9-b87d-40b8-9582-aac9ee89c8f8.  
# New Database id: 8f35dc3b-56ab-45df-a1cf-459b60aa7454
rename sharepoint central administration database

Now, Lets move all sites from Old database to New Database:
# Move central admin sites to from old Database to new SharePoint content database
Get-SPSite –ContentDatabase c633c573-966d-4362-a1f8-430fba561f11 | Move-SPSite –DestinationDatabase 8f35dc3b-56ab-45df-a1cf-459b60aa7454

#You must do an IISReset!
# Now, You can Remove OLD SharePoint admin content database using Old database ID - actually deletes the database on the SQL Server.
 Remove-SPContentDatabase -identity c633c573-966d-4362-a1f8-430fba561f11 

How to Avoid GUIDs in SharePoint Databases:
Prevention is better than cure! Always use PowerShell to to avoid GUIDs in SharePoint Databases. Do not run Products configuration wizard right after installation. Use PowerShell to create the SharePoint farm and service applications How to Create a SharePoint 2013 Farm using PowerShell?

No comments:

Please Login and comment to get your questions answered!

Powered by Blogger.