“Unable to connect to SharePoint database” – Issues with database connection, possibly related to SQL Server.

Loading

“Unable to Connect to SharePoint Database” – Detailed Troubleshooting Guide

The “Unable to connect to SharePoint database” error occurs when SharePoint cannot communicate with the SQL Server that hosts its databases. This issue can arise due to:

  • SQL Server being offline or misconfigured.
  • Incorrect database permissions for the SharePoint service account.
  • Network connectivity issues between the SharePoint server and SQL Server.
  • The SharePoint configuration database being in a problematic state (e.g., “Suspect” or “Offline”).

This step-by-step guide provides detailed troubleshooting instructions to identify and resolve the issue.


🔍 Step 1: Verify SQL Server is Running

If SQL Server is stopped or not accessible, SharePoint cannot connect to the database.

✅ How to Check SQL Server Status:

  1. Log in to the SQL Server where SharePoint databases are hosted.
  2. Open SQL Server Configuration Manager:
    • Press Win + R, type SQLServerManagerXX.msc (replace XX with your SQL version), and press Enter.
  3. Under SQL Server Services, check the status of:
    • SQL Server (MSSQLSERVER) – Ensure it is Running.
    • SQL Server Browser – Should be Running if using named instances.
  4. If any service is Stopped, right-click it and select Start.

✅ Alternative: Check via PowerShell

Run the following command to check SQL Server status:

Get-Service -Name *SQL*

If SQL Server is stopped, start it using:

Start-Service -Name "MSSQLSERVER"

🔍 Step 2: Verify SQL Server is Reachable from SharePoint Server

Even if SQL Server is running, SharePoint may fail to connect due to network issues.

✅ How to Test Connectivity:

  1. Ping the SQL Server from the SharePoint Server:
    • Open Command Prompt on the SharePoint Server.
    • Run: ping <SQL_Server_Name>
    • If the request times out, there is a network issue preventing connection.
  2. Test SQL Connection via Telnet:
    • Run: telnet <SQL_Server_Name> 1433
    • If it fails, SQL Server may not be listening on port 1433 or the port is blocked by a firewall.

✅ How to Allow SQL Server in Windows Firewall:

  1. Open Windows Defender Firewall on the SQL Server.
  2. Click Advanced SettingsInbound Rules.
  3. Ensure the following rules are Enabled:
    • SQL Server (TCP-In) – Port 1433
    • SQL Browser (UDP-In) – Port 1434 (for named instances)
  4. If missing, add a new rule for TCP Port 1433 and UDP Port 1434.

🔍 Step 3: Check SQL Server Authentication Mode

SharePoint requires Windows Authentication Mode for SQL Server access.

✅ How to Verify and Change Authentication Mode:

  1. Open SQL Server Management Studio (SSMS).
  2. Right-click the SQL Server instanceProperties.
  3. Go to the Security tab and check if Windows Authentication Mode is enabled.
  4. If it’s set to SQL Server and Windows Authentication Mode, change it to Windows Authentication Mode.
  5. Click OK, restart SQL Server, and test SharePoint connectivity again.

🔍 Step 4: Verify SharePoint Database Permissions

If the SharePoint service account lacks the correct database permissions, it won’t be able to connect.

✅ Steps to Check and Assign Proper Permissions:

  1. Open SQL Server Management Studio (SSMS).
  2. Expand SecurityLogins.
  3. Find the SharePoint Farm Account (e.g., SPFarm).
  4. Right-click the account and select Properties.
  5. Under Server Roles, ensure it has:
    • dbcreator
    • securityadmin
  6. Under User Mapping, ensure the SharePoint databases have:
    • db_owner assigned.

If permissions are missing, grant them and restart SharePoint/IIS.


🔍 Step 5: Check SharePoint Configuration Database State

If the SharePoint Configuration Database is corrupt or offline, SharePoint won’t be able to connect.

✅ Steps to Check Database Status:

  1. Open SQL Server Management Studio (SSMS).
  2. Run the following SQL query: SELECT name, state_desc FROM sys.databases;
  3. If the SharePoint Configuration Database is in Suspect or Offline state, bring it online: ALTER DATABASE SharePoint_Config SET ONLINE;
  4. If the database is still in Suspect mode, try the following: ALTER DATABASE SharePoint_Config SET EMERGENCY; DBCC CHECKDB ('SharePoint_Config', REPAIR_ALLOW_DATA_LOSS); ALTER DATABASE SharePoint_Config SET ONLINE;

🔍 Step 6: Restart IIS and SharePoint Timer Service

If database connectivity has been restored, restart IIS and SharePoint services.

✅ Restart IIS:

iisreset /noforce

✅ Restart SharePoint Timer Service:

Restart-Service SPTimerV4

🔍 Step 7: Verify SharePoint Database Connection Strings

If the SQL Server name has changed or databases were moved, SharePoint may be using an incorrect connection string.

✅ How to Check:

  1. Open SharePoint Central Administration.
  2. Navigate to Manage Servers in Farm.
  3. Ensure the database server listed is correct.
  4. If incorrect, update it using PowerShell: Set-SPDatabase -Identity "<DatabaseName>" -ServerInstance "<NewSQLServer>"

🔍 Step 8: Check Event Viewer for Errors

Event Viewer logs provide detailed error messages related to SQL Server connectivity.

✅ How to Check Event Logs:

  1. Open Event Viewer (eventvwr.msc).
  2. Go to Windows LogsApplication.
  3. Look for SharePoint, SQL Server, or IIS errors.
  4. If an error message appears, take action based on the details provided.

🔍 Step 9: Test Database Connection with PowerShell

If you suspect a connection issue, test it with PowerShell.

✅ Run the Following PowerShell Script:

$SQLServer = "YourSQLServerName"
$Database = "SharePoint_Config"
$Connection = New-Object System.Data.SqlClient.SqlConnection
$Connection.ConnectionString = "Server=$SQLServer;Database=$Database;Integrated Security=True"
Try {
    $Connection.Open()
    Write-Host "Connected Successfully" -ForegroundColor Green
} Catch {
    Write-Host "Connection Failed: $_" -ForegroundColor Red
} Finally {
    $Connection.Close()
}

If the script fails, SQL Server might be unreachable or incorrectly configured.


🔍 Step 10: Final Checks and Server Restart

  • Ensure all required services are running.
  • Double-check firewall settings and network connectivity.
  • Restart SQL Server, IIS, and the SharePoint Server as a last resort.

Leave a Reply

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