TechnitiumSoftware/DnsServer · error · Exception
The 'connectionString' parameter must not define 'Database'.
Error message
The 'connectionString' parameter must not define 'Database'. Configure the 'databaseName' parameter above instead.
What it means
The QueryLogsMySqlApp stores MySQL connection details across two separate config parameters: 'connectionString' (server/auth) and 'databaseName' (target schema). This error fires when the connectionString itself already contains a 'Database=' segment, because the app manages the database name independently and would otherwise double-specify it. The check strips spaces then does a case-insensitive search for 'Database='.
Source
Thrown at Apps/QueryLogsMySqlApp/App.cs:372
if (config is null)
throw new InvalidOperationException();
using JsonDocument jsonDocument = JsonDocument.Parse(config, _jsonParseOptions);
JsonElement jsonConfig = jsonDocument.RootElement;
bool enableLogging = jsonConfig.GetPropertyValue("enableLogging", false);
int maxQueueSize = jsonConfig.GetPropertyValue("maxQueueSize", 1000000);
_maxLogDays = jsonConfig.GetPropertyValue("maxLogDays", 0);
_maxLogRecords = jsonConfig.GetPropertyValue("maxLogRecords", 0);
_databaseName = jsonConfig.GetPropertyValue("databaseName", "DnsQueryLogs");
_connectionString = jsonConfig.GetPropertyValue("connectionString", null);
if (_connectionString is null)
throw new Exception("Please specify a valid connection string in 'connectionString' parameter.");
if (_connectionString.Replace(" ", "").Contains("Database=", StringComparison.OrdinalIgnoreCase))
throw new Exception("The 'connectionString' parameter must not define 'Database'. Configure the 'databaseName' parameter above instead.");
if (!_connectionString.TrimEnd().EndsWith(';'))
_connectionString += ";";
async Task ApplyConfig()
{
if (enableLogging)
{
await using (MySqlConnection connection = new MySqlConnection(_connectionString))
{
await connection.OpenAsync();
await using (MySqlCommand command = connection.CreateCommand())
{
command.CommandText = @$"
CREATE DATABASE IF NOT EXISTS `{_databaseName}`;
USE `{_databaseName}`;View on GitHub (pinned to d0484b6c1e)
Solutions
- Remove the 'Database=...' pair from the 'connectionString' config value, keeping only server/auth options (Server, Port, Uid, Pwd, etc.).
- Set (or keep) the desired schema via the 'databaseName' config parameter, which defaults to 'DnsQueryLogs'.
- Ensure no stray 'Database=' substring remains after editing, including spaces like 'Database ='.
Example fix
// before (dnsApp.config) "connectionString": "Server=localhost;Database=DnsQueryLogs;Uid=root;Pwd=pass;" // after "connectionString": "Server=localhost;Uid=root;Pwd=pass;", "databaseName": "DnsQueryLogs"
Defensive patterns
Strategy: validation
Validate before calling
// Run before ApplyConfig / before writing dnsApp.config
static void ValidateMySqlConnectionString(string cs)
{
if (cs.Replace(" ", "").Contains("Database=", StringComparison.OrdinalIgnoreCase))
throw new InvalidOperationException(
"connectionString must not contain 'Database='. Use the databaseName parameter.");
}
ValidateMySqlConnectionString(connectionString); Prevention
- Treat connectionString as server/auth-only; never paste a full string from another tool unchecked.
- Keep databaseName as the single source of truth for the schema in config templates.
- Add a CI check that greps dnsApp.config for 'Database=' inside connectionString.
When it happens
Trigger: Calling ApplyConfig with a JSON config whose 'connectionString' value includes a 'Database=...' key-value pair (e.g. 'Server=localhost;Database=DnsQueryLogs;Uid=root;'). The space-stripped case-insensitive Contains matches even 'Database =' or ' database='.
Common situations: Copying a working MySQL connection string from another tool (Workbench, EF Core, another app) that baked the schema into the string, then pasting it into the dnsApp.config connectionString field without removing the Database segment.
Related errors
- Please specify a valid connection string in 'connectionStrin
- Please specify a valid connection string in 'connectionStrin
- The 'connectionString' parameter must not define 'Database'.
- Please specify a valid connection string in 'connectionStrin
- The 'connectionString' parameter must not define 'Initial Ca
AI-assisted analysis of TechnitiumSoftware/DnsServer@d0484b6c1e (2026-08-13).
Data as JSON: /api/errors/77be592f75b26cf0.
Report an issue: GitHub.