WP-CLI error in connecting to the database

This is a very common wp-cli error while using MAMP. I installed wp-cli, exported the php version MAMP is using to the WP_CLI_PHP variable as recommended by the instructions. The output of $ wp --info is:

PHP binary: /Applications/MAMP/bin/php/php5.6.2/bin/php
PHP version:    5.6.2
php.ini used:   /Applications/MAMP/bin/php/php5.6.2/conf/php.ini
WP-CLI root dir:    phar://wp-cli.phar
WP-CLI global config:   
WP-CLI project config:  
WP-CLI version: 0.20.1

I’ve followed along with all the solutions for this, but I’m still getting a timeout and error in connecting to the database. I also have MAMP running while running wp-cli commands. Any ideas?

Related posts

1 comment

  1. After seeing a comment here about the issues that if-statements can have for wp-cli when used in the wp-config file, I went back and checked mine. The config file was using a number of if-statements to set the $config_file variable. I commented out this entire block and simply set the $config_file = "path_to_config". This seems to have done the trick.

Comments are closed.