nopSolutions/nopCommerce · critical · Exception
Unable to connect to the new database. Please try one more t
Error message
Unable to connect to the new database. Please try one more time
What it means
Identical retry logic to the SQL Server provider, but in MySqlDataProvider.CreateDatabase. After 'CREATE DATABASE IF NOT EXISTS' it polls DatabaseExists() up to triesToConnect times (1s sleep each); on the final failed probe it throws a bare Exception, halting installation.
Source
Thrown at src/Libraries/Nop.Data/DataProviders/MySqlDataProvider.cs:109
var command = connection.CreateCommand();
command.CommandText = query;
command.Connection.Open();
command.ExecuteNonQuery();
}
//try connect
if (triesToConnect <= 0)
return;
//sometimes on slow servers (hosting) there could be situations when database requires some time to be created.
//but we have already started creation of tables and sample data.
//as a result there is an exception thrown and the installation process cannot continue.
//that's why we are in a cycle of "triesToConnect" times trying to connect to a database with a delay of one second.
for (var i = 0; i <= triesToConnect; i++)
{
if (i == triesToConnect)
throw new Exception("Unable to connect to the new database. Please try one more time");
if (!DatabaseExists())
Thread.Sleep(1000);
else
break;
}
}
/// <summary>
/// Checks if the specified database exists, returns true if database exists
/// </summary>
/// <returns>
/// A task that represents the asynchronous operation
/// The task result contains the returns true if the database exists.
/// </returns>
public virtual async Task<bool> DatabaseExistsAsync()
{
tryView on GitHub (pinned to 64bdf2ff08)
Solutions
- Raise triesToConnect passed to CreateDatabase to allow more polling time.
- Confirm MySQL credentials and that the user has CREATE privileges and can see the target schema via DatabaseExists.
- Ensure the database name casing matches what MySQL reports (provider forces lowercase).
- Pre-create the MySQL database manually and retry installation.
Example fix
// before dataProvider.CreateDatabase(dbName, triesToConnect: 5); // after dataProvider.CreateDatabase(dbName, triesToConnect: 30);
Defensive patterns
Strategy: retry
Validate before calling
// Pre-flight: confirm MySQL reachable and creds valid
if (!dataProvider.DatabaseExists())
throw new InvalidOperationException("Cannot reach MySQL; check connection string before creating the database."); Try / catch
try { dataProvider.CreateDatabase(dbName, triesToConnect: 30); }
catch (Exception ex) when (ex.Message.Contains("Unable to connect to the new database"))
{ /* verify MySQL creds/casing/privileges, then retry install */ } Prevention
- Verify the MySQL user has CREATE privilege and the schema name casing matches.
- Use a generous triesToConnect for shared hosting lag.
- Confirm network/firewall allows the MySQL port from the app host.
When it happens
Trigger: Installing against MySQL where DatabaseExists() never returns true within the retry budget — MySQL server slow to register the new schema, the server is accepting connections but the new catalog is not yet visible, or the connection string/credentials are wrong.
Common situations: MySQL on shared hosting with provisioning lag; incorrect Username/Password so the connection silently fails each probe; database name casing mismatch (provider lowercases the name) making the existence check miss; MySQL started with skip-grant-tables or in a degraded state.
Related errors
- Unable to connect to the new database. Please try one more t
- Unable to connect to the new database. Please try one more t
- This database provider does not support backup
- This database provider does not support database shrinking.
- Data provider supports connection only with login and passwo
AI-assisted analysis of nopSolutions/nopCommerce@64bdf2ff08 (2026-08-13).
Data as JSON: /api/errors/457b2d765bf8419f.
Report an issue: GitHub.