{"record":{"id":"4fc5b859386e0022","repo":"nopSolutions/nopCommerce","slug":"data-provider-supports-connection-only-with-login","errorCode":null,"errorMessage":"Data provider supports connection only with login and password","messagePattern":"Data provider supports connection only with login and password","errorType":"exception","errorClass":"NopException","httpStatus":null,"severity":"error","filePath":"src/Libraries/Nop.Data/DataProviders/MySqlDataProvider.cs","lineNumber":292,"sourceCode":"    public virtual async Task<long> GetDatabaseSizeAsync()\n    {\n        using var currentConnection = CreateDataConnection();\n        var result = await currentConnection.QueryToListAsync<long>($\"SELECT ROUND(SUM(data_length + index_length) / 1024, 1) FROM information_schema.tables where table_schema='{GetConnectionStringBuilder().Database}' GROUP BY table_schema\");\n\n        return result.FirstOrDefault();\n    }\n\n    /// <summary>\n    /// Build the connection string\n    /// </summary>\n    /// <param name=\"nopConnectionString\">Connection string info</param>\n    /// <returns>Connection string</returns>\n    public virtual string BuildConnectionString(INopConnectionStringInfo nopConnectionString)\n    {\n        ArgumentNullException.ThrowIfNull(nopConnectionString);\n\n        if (nopConnectionString.IntegratedSecurity)\n            throw new NopException(\"Data provider supports connection only with login and password\");\n\n        var builder = new MySqlConnectionStringBuilder\n        {\n            Server = nopConnectionString.ServerName,\n            //Cast DatabaseName to lowercase to avoid case-sensitivity problems\n            Database = nopConnectionString.DatabaseName.ToLowerInvariant(),\n            AllowUserVariables = true,\n            UserID = nopConnectionString.Username,\n            Password = nopConnectionString.Password,\n            UseXaTransactions = false\n        };\n\n        return builder.ConnectionString;\n    }\n\n    /// <summary>\n    /// Gets the name of a foreign key\n    /// </summary>","sourceCodeStart":274,"sourceCodeEnd":310,"githubUrl":"https://github.com/nopSolutions/nopCommerce/blob/64bdf2ff08c8b39e65717bcf974fb43dc2ef68f2/src/Libraries/Nop.Data/DataProviders/MySqlDataProvider.cs#L274-L310","documentation":"MySqlDataProvider.BuildConnectionString rejects INopConnectionStringInfo with IntegratedSecurity=true. MySQL has no equivalent of SQL Server Windows Authentication in this provider, so the builder requires an explicit UserID/Password. It throws NopException before constructing the MySqlConnectionStringBuilder.","triggerScenarios":"Installation or configuration passes a connection-info object whose IntegratedSecurity flag is true (e.g., copied from a SQL Server config) while the selected provider is MySQL. The check fires before any connection attempt.","commonSituations":"Reusing a SQL Server appsettings/install model with IntegratedSecurity=true after switching to MySQL; admin UI checkbox 'Use integrated security' left on; default install template shipping with IntegratedSecurity=true.","solutions":["Set IntegratedSecurity=false and supply Username and Password for the MySQL connection.","If migrating from SQL Server, regenerate the connection configuration for MySQL rather than reusing it.","Validate the IntegratedSecurity flag against the chosen provider in install configuration validation."],"exampleFix":"// before\ninfo.IntegratedSecurity = true; // copied from SQL Server config\nvar cs = dataProvider.BuildConnectionString(info);\n\n// after\ninfo.IntegratedSecurity = false;\ninfo.Username = \"nop_user\";\ninfo.Password = \"********\";\nvar cs = dataProvider.BuildConnectionString(info);","handlingStrategy":"validation","validationCode":"if (connInfo.IntegratedSecurity)\n    throw new InvalidOperationException(\"MySQL provider requires Username/Password; disable IntegratedSecurity.\");\n// ensure Username/Password set\nvar cs = dataProvider.BuildConnectionString(connInfo);","typeGuard":"static bool RequiresSqlAuth(DataProviderType t) => t is DataProviderType.MySql or DataProviderType.PostgreSQL;","tryCatchPattern":"try { var cs = dataProvider.BuildConnectionString(connInfo); }\ncatch (NopException ex) when (ex.Message.Contains(\"only with login and password\"))\n{ /* clear IntegratedSecurity, collect Username/Password, rebuild */ }","preventionTips":["Do not reuse SQL Server connection templates with IntegratedSecurity=true for MySQL.","Validate the IntegratedSecurity flag against provider type at install time.","Always supply Username/Password for MySQL/PostgreSQL configs."],"tags":["database","mysql","configuration","connection-string","nopcommerce"],"backgroundTag":null,"analyzedSha":"64bdf2ff08c8b39e65717bcf974fb43dc2ef68f2","analyzedAt":"2026-08-13T21:19:38.062Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}