How to Create a New Content Database in SharePoint 2013 / 2016 using PowerShell?

Although a content database can accommodate up to 10,000 site collections in SharePoint, it’s not advisable to use it so, as the recommended size of the content database is < 200 GB in SharePoint 2013. Also, that could introduce Security, Backup-restore issues to affect your SLA.

When you create a new site collection in SharePoint, it picks the available database which has room. Let’s see How to create a new content database for SharePoint.

How to add a content database in SharePoint from the Central Administration site?

  1. Login to SharePoint App/WFE server as a Farm Administrator
  2. Open Central Administration >> Application Management >> Manage content databases 
  3. Click on the “Add a content Database” link
  4. On the Add Content Database page:
    • Specify a Web application for the new database.
    • Specify a database server to host the new database
    • Specify the number of site collections before a warning is issued. By default, this is 9,000. Specify the total number of sites that can be created in the database. By default, this is 15,000.
    • Click  “OK” to add new content database in SharePoint 2013.
How to Create a New Content Database in SharePoint 2013 using PowerShell

That’s a straightforward procedure, isn’t it?

A Content Database can only be attached to a single Web Application!

Create a New Content Database in SharePoint 2013 using PowerShell

While you can use SharePoint Central Administration to manage some of the things you need to do with content databases, PowerShell is the best tool for managing content databases efficiently. Here is how to add a new content database with PowerShell:

Syntax:

New-SPContentDatabase -Name <Content-DB-Name> -WebApplication <Web-App-Name or URL>

Here is an example:

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Variables for Database server and Content Database Name
$DatabaseServerName = "YOUR-DB-SERVER"
$DatabaseName = "Hosting_ContentDB_001"
$WebAppName = "SharePoint Hosting"

#Create content database
New-SPContentDatabase -Name $DatabaseName -DatabaseServer $DatabaseServerName -WebApplication $WebAppName -MaxSiteCount 100 -WarningSiteCount 80

This cmdlet should emit the newly created content database GUID something like:

Id       : faca5154-3c10-4db8-8677-a863b4fc6302
Tips: you cannot have one site collection spread over multiple content databases. But one content database can hold multiple site collections.

Tail: How to create a site collection in a specific Content Database?
If you want to create a new site collection in the new database, then there are different options available in SharePoint 2013. Here is my preferred way: You can create a new site collection in a specific content database by using PowerShell cmdlet New-SPSite cmdlet with -ContentDatabase parameter. Here is how:

New-SPSite https://your-web-app-url/sites/Your-Site-collection -OwnerAlias "SiteOwnerUserName" -ContentDatabase "ContentDatabaseName" -Name "Site-Name" -Description "Site-Description" -Template "STS#0"

Please note that the “ContentDatabaseName” must refer to an existing database created already.

Salaudeen Rajack

Salaudeen Rajack - SharePoint Expert with Two decades of SharePoint Experience. Love to Share my knowledge and experience with the SharePoint community, through real-time articles!

Leave a Reply

Your email address will not be published. Required fields are marked *