diff --git a/core/lib/Drupal/Core/Database/Database.php b/core/lib/Drupal/Core/Database/Database.php
index 870c2abce663b28277c865962fe6fb877794131a..08e2146bd81709468ecde902cf038e3167be8b3d 100644
--- a/core/lib/Drupal/Core/Database/Database.php
+++ b/core/lib/Drupal/Core/Database/Database.php
@@ -468,7 +468,7 @@ public static function convertDbUrlToConnectionInfo($url, $root) {
     $url_components = parse_url($url);
     if (isset($url_components['query'])) {
       parse_str($url_components['query'], $query);
-      if ($query['module']) {
+      if (isset($query['module']) && $query['module']) {
         $module = $query['module'];
         // Set up an additional autoloader. We don't use the main autoloader as
         // this method can be called before Drupal is installed and is never
diff --git a/core/tests/Drupal/Tests/Core/Database/UrlConversionTest.php b/core/tests/Drupal/Tests/Core/Database/UrlConversionTest.php
index ca7e4ceff383aaa2904913b7d472fe025bffa1ad..a3e7325f21dcccee8b23c854d1b21e0f0254fe43 100644
--- a/core/tests/Drupal/Tests/Core/Database/UrlConversionTest.php
+++ b/core/tests/Drupal/Tests/Core/Database/UrlConversionTest.php
@@ -188,6 +188,19 @@ public function providerConvertDbUrlToConnectionInfo() {
           'autoload' => 'core/modules/system/tests/modules/driver_test/src/Driver/Database/DrivertestPgsql/',
         ],
       ],
+      'MySql with a custom query parameter' => [
+        '',
+        'mysql://test_user:test_pass@test_host:3306/test_database?extra=value',
+        [
+          'driver' => 'mysql',
+          'username' => 'test_user',
+          'password' => 'test_pass',
+          'host' => 'test_host',
+          'database' => 'test_database',
+          'port' => 3306,
+          'namespace' => 'Drupal\Core\Database\Driver\mysql',
+        ],
+      ],
     ];
   }