我的 drush 没有 运行 命令到数据库 (apache)

My drush doen't run commands to database (apache)

我已经在 Mac(El Capitan) 上的 apache 中设置了虚拟主机。我的所有项目都位于我的 Users/MyName/Sites 中,并且我安装了 Drush。我可以使用 drush 下载 stuf,例如:drush dl drupal。但是当我尝试使用 drush 启用模块时,我得到以下信息:

Command pm-enable needs a higher bootstrap level to run - you will [error]
need to invoke drush from a more functional Drupal environment to run
this command.
The drush command 'en admin_toolbar' could not be executed.         [error]
Drush was not able to start (bootstrap) the Drupal database.         [error]
Hint: 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.
* connect the database through a socket. The socket file may be
wrong or the php-cli may have no access to it in a jailed shell. See
http://drupal.org/node/1428638 for details.

Drush was attempting to connect to: 
Drupal version        :  7.41                                      
Site URI              :  http://default                            
Database driver       :  mysql                                     
Database hostname     :  localhost                                 
Database port         :                                            
Database username     :  root                                      
Database name         :  MyDatabase                                 
PHP executable        :  /usr/bin/php                              
PHP configuration     :                                            
PHP OS                :  Darwin                                    
Drush script          :  /Users/kim/.composer/vendor/drush/drush/drush.php                                  
Drush version         :  8.1-dev                                   
Drush temp directory  :  /tmp                                                          
Drush configuration   :                                            
Drush alias files     :                                            
Drupal root           :  /Users/MyName/Sites/MyProject                          
Site path             :  sites/default

我的猜测是我的 drush 没有正确配置我的数据库设置,但我不知道如何解决这个问题,或者这是否是真正的问题。如果有人可以帮助我,那就太好了!

我最近遇到了类似的错误。结果我需要将 mysql 添加到系统路径,我通过将下面的行添加到我的 .bash_profile 来完成。我正在使用 MAMP,因此您可能需要调整设置路径。

导出路径=$路径:/Applications/MAMP/Library/bin/

我自己修好了,对于 apache,.bash_profile 中的路径是

export PATH="/usr/local/mysql/bin:$PATH"