Troubleshooting Guide: SQL Server Error 5804 — Character Set / Configuration Mismatch
Why This Error Happens
Error 5804 typically occurs when SQL Server 2025 detects a mismatch between the character set configuration stored in the instance’s registry settings and the actual collation or locale configured during setup. This often happens after an incomplete installation, a corrupted master database resource file, or when the server’s regional/locale settings on Windows Server 2025 or Windows 11 were changed after SQL Server was installed. In some cases, this is also triggered by a damaged Resource.ide or Resource.mdf file not matching the installed code page.
Step-by-Step Resolution Guide
Step 1: Verify the Server Collation and Locale Settings
- Open SQL Server Management Studio (SSMS) and run:
SELECT SERVERPROPERTY('Collation'); - Compare the returned collation with the OS locale under Control Panel > Region > Administrative > Language for non-Unicode programs.
- Note any mismatch between the SQL Server collation code page and the Windows system locale.
Step 2: Rebuild the Master Database with Correct Collation
- Open Command Prompt as Administrator and navigate to the SQL Server installation binn directory, typically:
C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Binn - Run the setup rebuild command:
setup.exe /QUIET /ACTION=REBUILDDATABASE /INSTANCENAME=MSSQLSERVER /SQLSYSADMINACCOUNTS=BUILTIN\Administrators /SAPWD=<StrongPassword> /SQLCOLLATION=SQL_Latin1_General_CP1_CI_AS
- Replace
SQL_Latin1_General_CP1_CI_ASwith the collation matching your application’s required character set.
Step 3: Check and Restore the Resource Database Files
- Navigate to:
C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Binn\Templates - Confirm
Resource.mdfandResource.ldfexist and are not zero-byte or corrupted. - If corrupted, restore these files from the original installation media or a verified backup, then restart the SQL Server (MSSQLSERVER) service via services.msc.
Step 4: Restart SQL Server Services and Validate Configuration
- Open services.msc on Windows Server 2025/Windows 11.
- Restart SQL Server (MSSQLSERVER) and SQL Server Agent services.
- Re-run:
SELECT SERVERPROPERTY('Collation');to confirm the setting now matches the expected character set.
Alternative or Verification Steps
- Run
DBCC CHECKDB('master')to confirm no further corruption exists after the rebuild, and test data retrieval queries that previously failed due to Error 5804. - If the issue persists, perform a full uninstall/reinstall of the SQL Server 2025 instance, explicitly specifying the correct
/SQLCOLLATIONparameter during setup to prevent recurrence.