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 a SharePoint central administration database with GUIDs. E.g. SharePoint_AdminContent_a149fa83-d2b9-4ad9-9e4c-ad12f73f0dd6.
Your DBA’s may not be happy with these GUIDs as they deviate from database naming standards. So, let’s rename the SharePoint Central administration content database with the following 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 https://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 the Options tab. Set the database restricted access property 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”.
Step 3. Attach the renamed Content Database
Attach the renamed content database back to the Central Administration web application: (PowerShell: Mount-SPContentDatabase)
stsadm -o addcontentdb -url https://centraladmin:2013 -databasename SharePoint_AdminContent
An alternate approach to rename the SharePoint database:
Alternatively, You can create a new content database with the right naming conventions, move all sites from the existing content database to the new one, and then remove the old one. Here is the script:
#Create new Content Database
New-SPContentDatabase -Name SharePoint_AdminContent -WebApplication https://centraladmin:2013
Now the Central Admin should have two databases attached with it.
Let’s get the IDs of those two databases:
# Get SharePoint database IDs for old and new DBs for central admin site
Get-SPWebApplication -Identity https://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
Now, let’s move all sites from the 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!
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 avoid GUIDs in SharePoint Databases. Do not run the 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?