diff --git a/core/includes/common.inc b/core/includes/common.inc
index c6f6688..a2c3eae 100644
--- a/core/includes/common.inc
+++ b/core/includes/common.inc
@@ -4789,7 +4789,7 @@ function drupal_flush_all_caches() {
  */
 function _drupal_flush_css_js() {
   // The timestamp is converted to base 36 in order to make it more compact.
-  variable_set('css_js_query_string', base_convert(REQUEST_TIME, 10, 36));
+  Drupal::state()->set('system.css_js_query_string', base_convert(REQUEST_TIME, 10, 36));
 }
 
 /**
diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc
index 8e4b66e..94cd509 100644
--- a/core/includes/install.core.inc
+++ b/core/includes/install.core.inc
@@ -422,6 +422,13 @@ function install_begin_request(&$install_state) {
       ))
       ->addMethodCall('setUserAgent', array('Drupal (+http://drupal.org/)'));
 
+    $container->register('keyvalue', 'Drupal\Core\KeyValueStore\KeyValueFactory')
+      ->addArgument(new Reference('service_container'));
+    $container->register('keyvalue.memory', 'Drupal\Core\KeyValueStore\KeyValueMemoryFactory');
+    // Override the default keyvalue storage to use memory as the database is
+    // not available.
+    $conf['keyvalue_default'] = 'keyvalue.memory';
+
     // Register the expirable key value store used by form cache.
     $container
       ->register('keyvalue.expirable', 'Drupal\Core\KeyValueStore\KeyValueExpirableFactory')
@@ -1201,7 +1208,7 @@ function install_database_errors($database, $settings_file) {
  * @see install_settings_form_validate()
  */
 function install_settings_form_submit($form, &$form_state) {
-  global $install_state;
+  global $install_state, $conf;
 
   // Update global settings array and save.
   $settings = array();
@@ -1239,6 +1246,10 @@ function install_settings_form_submit($form, &$form_state) {
   // Add the config directories to settings.php.
   drupal_install_config_directories();
 
+  // The container is about to be rebuilt so we need to unset the keyvalue
+  // storage override that the installer is using.
+  unset($conf['keyvalue_default']);
+
   // Indicate that the settings file has been verified, and check the database
   // for the last completed task, now that we have a valid connection. This
   // last step is important since we want to trigger an error if the new
diff --git a/core/lib/Drupal/Core/Asset/CssCollectionRenderer.php b/core/lib/Drupal/Core/Asset/CssCollectionRenderer.php
index 6d36ede..aa700d0 100644
--- a/core/lib/Drupal/Core/Asset/CssCollectionRenderer.php
+++ b/core/lib/Drupal/Core/Asset/CssCollectionRenderer.php
@@ -24,7 +24,7 @@ public function render(array $css_assets) {
     // browser-caching. The string changes on every update or full cache
     // flush, forcing browsers to load a new copy of the files, as the
     // URL changed.
-    $query_string = variable_get('css_js_query_string', '0');
+    $query_string = \Drupal::state()->get('system.css_js_query_string') ?: '0';
 
     // Defaults for LINK and STYLE elements.
     $link_element_defaults = array(
diff --git a/core/lib/Drupal/Core/Asset/JsCollectionRenderer.php b/core/lib/Drupal/Core/Asset/JsCollectionRenderer.php
index b9f6582..ee13f5f 100644
--- a/core/lib/Drupal/Core/Asset/JsCollectionRenderer.php
+++ b/core/lib/Drupal/Core/Asset/JsCollectionRenderer.php
@@ -1,5 +1,6 @@
 <?php
 
+
 /**
  * Contains \Drupal\Core\Asset\JsCollectionRenderer.
  */
@@ -25,7 +26,7 @@ public function render(array $js_assets) {
     // URL changed. Files that should not be cached (see drupal_add_js())
     // get REQUEST_TIME as query-string instead, to enforce reload on every
     // page request.
-    $default_query_string = variable_get('css_js_query_string', '0');
+    $default_query_string = \Drupal::state()->get('system.css_js_query_string') ?: '0';
 
     // For inline JavaScript to validate as XHTML, all JavaScript containing
     // XHTML needs to be wrapped in CDATA. To make that backwards compatible
diff --git a/core/modules/system/lib/Drupal/system/Tests/Common/CascadingStylesheetsTest.php b/core/modules/system/lib/Drupal/system/Tests/Common/CascadingStylesheetsTest.php
index 54abcba..052ea57 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Common/CascadingStylesheetsTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Common/CascadingStylesheetsTest.php
@@ -78,7 +78,7 @@ function testRenderFile() {
     $styles = drupal_get_css();
     $this->assertTrue(strpos($styles, $css) > 0, 'Rendered CSS includes the added stylesheet.');
     // Verify that newlines are properly added inside style tags.
-    $query_string = variable_get('css_js_query_string', '0');
+    $query_string = $this->container->get('state')->get('system.css_js_query_string') ?: '0';
     $css_processed = '<link rel="stylesheet" href="' . check_plain(file_create_url($css)) . "?" . $query_string . '" media="all" />';
     $this->assertEqual(trim($styles), $css_processed, 'Rendered CSS includes newlines inside style tags for JavaScript use.');
   }
@@ -184,7 +184,7 @@ function testAddCssFileWithQueryString() {
     drupal_add_css($css_with_query_string);
 
     $styles = drupal_get_css();
-    $query_string = variable_get('css_js_query_string', '0');
+    $query_string = $this->container->get('state')->get('system.css_js_query_string') ?: '0';
     $this->assertTrue(strpos($styles, $css_without_query_string . '?' . $query_string), 'Query string was appended correctly to css.');
     $this->assertTrue(strpos($styles, str_replace('&', '&amp;', $css_with_query_string)), 'Query string not escaped on a URI.');
   }
diff --git a/core/modules/system/lib/Drupal/system/Tests/Common/JavaScriptTest.php b/core/modules/system/lib/Drupal/system/Tests/Common/JavaScriptTest.php
index 96168fe..28c445e 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Common/JavaScriptTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Common/JavaScriptTest.php
@@ -101,7 +101,7 @@ function testAddExternal() {
    * Tests adding JavaScript files with additional attributes.
    */
   function testAttributes() {
-    $default_query_string = variable_get('css_js_query_string', '0');
+    $default_query_string = $this->container->get('state')->get('system.css_js_query_string') ?: '0';
 
     drupal_add_library('system', 'drupal');
     drupal_add_js('http://example.com/script.js', array('attributes' => array('defer' => 'defer')));
@@ -122,7 +122,7 @@ function testAggregatedAttributes() {
     // Enable aggregation.
     \Drupal::config('system.performance')->set('js.preprocess', 1)->save();
 
-    $default_query_string = variable_get('css_js_query_string', '0');
+    $default_query_string = $this->container->get('state')->get('system.css_js_query_string') ?: '0';
 
     drupal_add_library('system', 'drupal');
     drupal_add_js('http://example.com/script.js', array('attributes' => array('defer' => 'defer')));
@@ -275,7 +275,7 @@ function testDifferentWeight() {
    * @see drupal_pre_render_conditional_comments()
    */
   function testBrowserConditionalComments() {
-    $default_query_string = variable_get('css_js_query_string', '0');
+    $default_query_string = $this->container->get('state')->get('system.css_js_query_string') ?: '0';
 
     drupal_add_library('system', 'drupal');
     drupal_add_js('core/misc/collapse.js', array('browsers' => array('IE' => 'lte IE 8', '!IE' => FALSE)));
@@ -304,7 +304,7 @@ function testVersionQueryString() {
    * Tests JavaScript grouping and aggregation.
    */
   function testAggregation() {
-    $default_query_string = variable_get('css_js_query_string', '0');
+    $default_query_string = $this->container->get('state')->get('system.css_js_query_string') ?: '0';
 
     // To optimize aggregation, items with the 'every_page' option are ordered
     // ahead of ones without. The order of JavaScript execution must be the
@@ -563,7 +563,7 @@ function testAddJsFileWithQueryString() {
     $js = drupal_get_path('module', 'node') . '/node.js';
     drupal_add_js($js);
 
-    $query_string = variable_get('css_js_query_string', '0');
+    $query_string = $this->container->get('state')->get('system.css_js_query_string') ?: '0';
     $scripts = drupal_get_js();
     $this->assertTrue(strpos($scripts, $js . '?' . $query_string), 'Query string was appended correctly to JS.');
   }
diff --git a/core/modules/system/system.install b/core/modules/system/system.install
index a4e7926..4efdc66 100644
--- a/core/modules/system/system.install
+++ b/core/modules/system/system.install
@@ -1721,12 +1721,13 @@ function system_update_8031() {
 }
 
 /**
- * Remove the drupal_js_cache_files variable.
+ * Remove the drupal_js_cache_files and system.css_js_query_string variables.
  *
  * @ingroup config_upgrade
  */
 function system_update_8032() {
   update_variable_del('drupal_js_cache_files');
+  update_variable_del('system.css_js_query_string');
 }
 
 /**
