SituationIf a client provides a database backup of the SharePoint site running on their server and we want to use that database in our environment. Using powershell we have to change the mounting of database and use the database what client sent.
PrerequesitesRestore the database given by client in your Sharepoint database instance. Once that is done run the below given powershell in "SharePoint 2010 Management Shell".
# Url of the site collection which the database is going to point $SiteUrl = "http://MyMachine" # The current database site is using. $CurrentContentDatabase = "WSS_Content" # New database which the site will point $NewContentDatabase = "WSS_Content_NewDB" # SQL SERVER Instanne $DatabaseServer = "MYMachine\SHAREPOINT" # The command will dismount the current databae Dismount-SPContentDatabase -Identity $CurrentContentDatabase -confirm:$false # Mounts the new database Mount-SPContentDatabase -name $NewContentDatabase -DatabaseServer $DatabaseServer -WebApplication $SiteUrl -confirm:$false