php - Command cim was not found. Drush was unable to query the database
drush cim commands in Drupal 8 I get the following error:
Command cim was not found. Drush was unable to query the database. As a result, many commands are unavailable. Re-run your command with --debug to see relevant log messages.
and when I run the
drush cim --debug show the following:
$ drush cim --debug [preflight] Redispatch to site-local Drush: C:\xampp\htdocs\executive-coatings\docroot/vendor/drush/drush/drush. [preflight] Config paths: C:/xampp/htdocs/executive-coatings/docroot/vendor/drush/drush/drush.yml [preflight] Alias paths: C:/xampp/htdocs/executive-coatings/docroot/drush/sites,C:/xampp/htdocs/executive-coatings/drush/sites,C:/xampp/htdocs/executive-coatings/docroot/drush/sites [preflight] Commandfile search paths: C:\xampp\htdocs\executive-coatings\docroot\vendor\drush\drush\src [debug] Bootstrap further to find cim [0.27 sec, 6.78 MB] [debug] Trying to bootstrap as far as we can [0.27 sec, 6.78 MB] [bootstrap] Drush bootstrap phase: bootstrapDrupalRoot() [0.27 sec, 6.78 MB] [bootstrap] Change working directory to C:\xampp\htdocs\executive-coatings\docroot [0.27 sec, 6.78 MB] [bootstrap] Initialized Drupal 8.6.13 root directory at C:\xampp\htdocs\executive-coatings\docroot [0.28 sec, 6.9 MB] [bootstrap] Drush bootstrap phase: bootstrapDrupalSite() [0.28 sec, 7.15 MB] [bootstrap] Initialized Drupal site default at sites/default [0.29 sec, 7.37 MB] [debug] Could not find a Drupal settings.php file at sites/default/settings.php. [0.29 sec, 7.37 MB] [bootstrap] Drush bootstrap phase: bootstrapDrupalConfiguration() [0.29 sec, 7.37 MB] [debug] Add service modifier [0.29 sec, 7.51 MB] [bootstrap] Unable to connect to database. More information may be available by running `drush status`. This may occur when Drush is trying to bootstrap a site that has not been installed or does not have a configured database. In this case you can select another site with a working database setup by specifying the URI to use with the --uri parameter on the command line. See `drush topic docs-aliases` for details. [0.29 sec, 7.51 MB] [debug] Bootstrap phase bootstrapDrupalDatabase() failed to validate; continuing at bootstrapDrupalConfiguration() [0.29 sec, 7.51 MB] [debug] Done with bootstrap max in Application::find(): trying to find cim again. [0.29 sec, 7.51 MB] In Application.php line 239: [Symfony\Component\Console\Exception\CommandNotFoundException] Command cim was not found. Drush was unable to query the database. As a result, many commands are unavailable. Re-r un your command with --debug to see relevant log messages. Exception trace: () at C:\xampp\htdocs\executive-coatings\docroot\vendor\drush\drush\src\Application.php:239 Drush\Application->bootstrapAndFind() at C:\xampp\htdocs\executive-coatings\docroot\vendor\drush\drush\src\Application.php:192 Drush\Application->find() at C:\xampp\htdocs\executive-coatings\docroot\vendor\symfony\console\Application.php:236 Symfony\Component\Console\Application->doRun() at C:\xampp\htdocs\executive-coatings\docroot\vendor\symfony\console\Application.php:148 Symfony\Component\Console\Application->run() at C:\xampp\htdocs\executive-coatings\docroot\vendor\drush\drush\src\Runtime\Runtime.php:118 Drush\Runtime\Runtime->doRun() at C:\xampp\htdocs\executive-coatings\docroot\vendor\drush\drush\src\Runtime\Runtime.php:49 Drush\Runtime\Runtime->run() at C:\xampp\htdocs\executive-coatings\docroot\vendor\drush\drush\drush.php:72 require() at C:\xampp\htdocs\executive-coatings\docroot\vendor\drush\drush\drush:4
You probably (like me) are trying to import all the exported configurations from some existing-site (from here on referenced as
example.com) into your local (
localhost/PROJECT_NAME) for development reasons, but that is currently (middle 2019) not directly supported, and you will have to import the database first, see below for more.
DATABASE_NAME) and import previously exported one, using
PhpMyAdmin(or something like that, e.g. http://localhost/phpmyadmin/).
settings.local.phpfile exists (in
./sites/default/settingsdirectory), and when it does not exist create it and configure it, for example like:
settings.phpfile exists (in
./sites/defaultdirectory), and that it includes above mentioned
settings.local.phpfile (will attach my default
localhost/PROJECT_NAME/core/install.php?rewrite=ok&langcode=en&profile=standard&continue=1link (just to ensure it shows Drupal is already installed).
drush cr(it should now work and clear the cache).
This is my default
settings.phpfile, which should include
settings.local.php(if it exists).
Please run this command
drush config-importbefore you run
For more info please refer to this link here I hope it solves your problem.
In my case, I just did not started virtual server (wamp).