未找到 cim 命令。Drush 无法查询数据库

Kha*_*zad 6 php drupal drush drupal-8

在 Drupal 8 中运行drush cim命令时,出现以下错误:

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.
Run Code Online (Sandbox Code Playgroud)

当我运行节目时,drush cim --debug显示以下内容:

$ 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
Run Code Online (Sandbox Code Playgroud)

Moh*_*ada -2

请考虑以下步骤,因为它有可能解决您的问题。

  1. 清除 Drush 缓存:清除 Drush 缓存可能有助于解决以下问题:drush cache-clear drush
  2. 验证 Drupal 安装中是否启用了配置模块drush pm:list --type=module | grep config,如果未列出配置模块,您可以使用以下命令启用它:drush pm:enable config
  3. 您可以尝试使用 --debug 选项运行该命令来获取更详细的日志消息。这可以提供有关问题的更多信息并帮助排除故障。

  • 无意冒犯,但我认为在没有任何进一步研究和解释的情况下得出这一结论是误导性的。 (6认同)
  • 我认为“cim”和“config-import”是相同的。https://drushcommands.com/drush-8x/config/config-import/ (3认同)
  • “drush config-import”命令给我带来了与“drush cim”完全相同的错误,因此,我发布了[对我有用的内容](/sf/answers/3991353131/)。 (3认同)
  • @MohammadAzizNabizada 有这方面的官方文档吗? (2认同)