Monday, 15 October 2012

Rewire Content Database

this is the final post in reference to restoring your content database. Here I'll cover how to rewire the db permissions so that your user can actually do something with the db.

lets set our focus back to Microsoft sql server management studio.

Check under security for your machine and make sure that the user account you’re concerned with is available. in my case it's ssrap7/Administrator and to remind you my content database is WSS_Content. as you can see below, ssrap7/administrator is not included in my content database so I'm going to go ahead and add it.

to add a new user simply right click on your content database and hit add user, just make sure to select db_owner, refer to image below.

now with with db_owner checked off click the OK button. Next run the following Powershell


function LoadSharePointPowerShellEnviroment
{
                write-host
                write-host "Setting up Powershell enviroment for Sharepoint" -foregroundcolor Blue
                Add-PSSnapin "Microsoft.Sharepoint.PowerShell" -ErrorAction SilentlyContinue
                Write-host "Sharepoint PowerShell Snapin loaded." -foregroundcolor Green
}
LoadSharePointPowerShellEnviroment
Mount-SPContentDatabase "WSS_Content" -DatabaseServer "SSRAP7" -WebApplication
http://SSRAP7/

make sure to specify your database name, database server, and web application URL.

once you've run the power shell, you must add your account as local site admin

Open central administration-> application management ->Select Change site Collection administrators

This will show you the site collection administrators set the primary site collection administrator to your local administrator


hit ok, and BAM, you're done.