To create a new web application which will use an existing content database we need to do the following.
Open Sql Server Management Studio
To take back up of the database in my case it was ‘WSS_Content_fa5cc7a0686e424bbe4fc128b4a48cf4’
Right click the database — select tasks —select Offline—then select Detach.
Get the mdf and ldf file for the database.
Attach the files and create a new database.
Now to Central Administration Site — Application Management — Create a new web application
Let the name of the database as default.
Now go to Content Database within Application Management — Select the web application just created.
Click on the Database Name — Select Database Status as Offline and Check Remove Content database check box.
Now click on Add Content Database— In the Database Name specify the name of the new restored database.
This is the point we can get this error “A SharePoint database named ‘….. ‘already exists. You must supply another name for the new database”
The solution for this is to go to
SharePoint_Config database —There run this query
delete from Objects where name=’name of restored db’;