昨日MAMP 4にアップグレードしましたが、私の生涯Drushを接続できません。 MAMP 3でも同様の問題があったと思いますが、次の方法で問題が解決しました。今回は運がありません。
Sudo mkdir /var/mysql
Sudo ln -s /Applications/MAMP/tmp/mysql/mysql.sock /var/mysql/mysql.sock
何か案は? DrushをComposerとともにグローバルにインストールしました。ここにエラーがあります:
Command pm-update 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 'pm-update' 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.50
Site URI : http://default
Database driver : mysql
Database hostname : localhost
Database port :
Database username : root
Database name : ba_dev
PHP executable : /usr/local/bin/php
PHP configuration : /usr/local/etc/php/5.5/php.ini
PHP OS : Darwin
Drush script : /Users/ja/.composer/vendor/drush/drush
/drush.php
Drush version : 8.1.3
Drush temp directory : /tmp
Drush configuration :
Drush alias files :
Drupal root : /Users/ja/Sites/ba/public_html
Drupal Settings File : sites/default/settings.php
Site path : sites/default
次のコードを.bash_profileファイルに追加し、PHPバージョンをMAMPの内容と一致するように変更します。これでうまくいきました。
export PATH="/Applications/MAMP/Library/bin:/Applications/MAMP/bin/php/php5.4.45/bin:$PATH"
export PATH="/Applications/MAMP/Library/bin:/Applications/MAMP/bin/php/php5.5.38/bin:$PATH"
export PATH="/Applications/MAMP/Library/bin:/Applications/MAMP/bin/php/php5.6.25/bin:$PATH"
export PATH="/Applications/MAMP/Library/bin:/Applications/MAMP/bin/php/php7.0.10/bin:$PATH"
この実行後:
source ~/.bash_profile