In the world of technology, we often need to migrate the user data from one place to another place in order to keep the application up-to-date. For the same reason, in SharePoint, we often migrate our content database from one farm to another farm or one version to another version.
So here, I will explain the easy method to move your content database from one environment to another environment. I will move the content database called “EDEMO” from http://dev.sharepoint.com environment to http://prod.sharepoint.com.
Note
Before proceeding, make sure that you have taken the SQL backup and stored it in a different location and made sure that both SharePoint Farms are using the same database version.
In my case, I have taken the SQL backup and stored it in a different drive and as my first step, I made that database status offline by clicking Application Management -> Manage Content Database -> click that database and change the status to offline.
Step 2
Go to SQL Server and open Management Studio. Then, select that database, right-click, and choose Tasks >> Detach.
On the next pop-up, tick "Drop Connections" and "Update Statistics" options to detach the database smoothly.
Or, you can run the below-mentioned PowerShell script to detach the content database.
- Dismount-SPContentDatabase –WebApplication http:
Note
Don’t execute Remove-SPContentDatabase cmdlets, it will remove the content database permanently.
Step 3
Go to your database storage location to grab the .mdb file and log file to move to the destination location. In my case, I installed SQL to c:\\programfiles\MSSQL\instanceName\Data.
Step 4
Once you've moved the database to the destination location, open Management Studio on the destination server and right-click the database folder. Select the "Attach" option.
Step 5
On the next pop-up, click ADD, as highlighted below.
Step 6
Browse your .mdb file and click OK.
Step 7
Once you have selected the .mdb file, it will automatically include the log file also and click OK after verifying the options.
Step 8
Now, it will take a few minutes to attach the content database.
Step 9
Navigate to the "Manage content database" page and you can use the "Add Content database" option there to attach the database to your web application
Step 10
You can run the below mentioned PowerShell command to attach the content database to the respective web application.
- Mount-SPContentDatabse –WebApplication http:
Step 11
Once the command executed successfully, then navigate to the manage content database and see whether content database is attached correctly or not.
Another method to verify if the content database is successfully attached to the respective web application is by navigating Central Administration -> Application Management -> View all Site Collections.
Here, you can see all the site collection information which was available in the content database.