web-dev-qa-db-fra.com

installation de wp-cli

j'ai installé 0h-my-zsh; puis wp-cli, changez le fichier .zshrc et a écrit:

# FIX PHP MAMP for WP-CLI
export PATH=/Applications/MAMP/bin/php/php5.6.2/bin:$PATH
export PATH=$PATH:/Applications/MAMP/Library/bin/

à cause de mamp (que j'utilise).

Puis déplacez-vous vers un répertoire WordPress et essayez d'installer un plugin:

wp plugin install *name-of-the-plugin*.

mais j'ai un message d'erreur:

Warning: mysqli_real_connect(): (HY000/2002): No such file or directory in
/Applications/MAMP/htdocs/Wp theme dev/wp-includes/wp-db.php on line 1452
Deprecated: mysql_connect(): The mysql extension is deprecated and will be     
removed in the future: use mysqli or PDO instead in /Applications/MAMP/htdocs/Wp   
theme dev/wp-includes/wp-db.php on line 1482
Warning: mysql_connect(): No such file or directory in 
/Applications/MAMP/htdocs/Wp theme dev/wp-includes/wp-db.php on line 1482
Error:
<h1>Error establishing a database connection</h1>
<p>This either means that the username and password information in your   
<code>wp-config.php</code> file is incorrect or we can't contact the database  
server at <code>localhost</code>. This could mean your Host's database server is  
down.</p>
<ul>
<li>Are you sure you have the correct username and password?</li>
<li>Are you sure that you have typed the correct hostname?</li>
<li>Are you sure that the database server is running?</li>
</ul>
<p>If you're unsure what these terms mean you should probably contact your Host.  
If you still need help you can always visit the <a  
href='https://wordpress.org/support/'>WordPress Support Forums</a>.</p>

j'ai tapé

echo $PATH 

et voici le résultat :

/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

puis,

wp --info :

PHP binary: /usr/bin/php
PHP version:    5.5.27
php.ini used:
WP-CLI root dir:    phar://wp-cli.phar
WP-CLI global config:
WP-CLI project config:
WP-CLI version: 0.19.2

je suis un peu confus. Où est-ce que je me suis trompé?

1
Christophe

J'ai trouvé mon erreur dans le fichier php.ini utilisé. Dans mon fichier .zshrc, je change la version de php en bonne version (5.5.10) et maintenant, wp.cli fonctionne bien.

1
Christophe