diff --git a/main/install/install.lib.php b/main/install/install.lib.php
index a9e2d760b1..4b5bde2ec6 100755
--- a/main/install/install.lib.php
+++ b/main/install/install.lib.php
@@ -1563,12 +1563,6 @@ function display_database_settings_form(
$tableDropWorks = $schemaManager->tablesExist($table) === false;
}
} else {
- $schemaManager = $manager->getConnection()->getSchemaManager();
- $databases = $schemaManager->listDatabases();
- if (in_array($dbNameForm, $databases)) {
- $database_exists_text = '
'.get_lang('ADatabaseWithTheSameNameAlreadyExists').'
';
- }
-
$manager = connectToDatabase(
$dbHostForm,
$dbUsernameForm,
@@ -1576,6 +1570,12 @@ function display_database_settings_form(
null,
$dbPortForm
);
+
+ $schemaManager = $manager->getConnection()->getSchemaManager();
+ $databases = $schemaManager->listDatabases();
+ if (in_array($dbNameForm, $databases)) {
+ $database_exists_text = ''.get_lang('ADatabaseWithTheSameNameAlreadyExists').'
';
+ }
}
} catch (Exception $e) {
$database_exists_text = $e->getMessage();