Wordpress Can';t使用WP-CLI安装插件

Wordpress Can';t使用WP-CLI安装插件,wordpress,Wordpress,我无法使用WP CLI安装插件。任何帮助都将不胜感激 我在Windows10上运行一个本地WordPress站点,使用MAMP。我在Ubuntu终端上使用WP CLI,它在我的Windows 10机器上的VirtualBox上运行 在Ubuntu终端中,当我尝试运行wp plugin install jetpack时,我收到以下错误消息: PHP Warning: mysqli_real_connect(): (HY000/2002): No such file or directory i

我无法使用WP CLI安装插件。任何帮助都将不胜感激

我在Windows10上运行一个本地WordPress站点,使用MAMP。我在Ubuntu终端上使用WP CLI,它在我的Windows 10机器上的VirtualBox上运行

在Ubuntu终端中,当我尝试运行
wp plugin install jetpack
时,我收到以下错误消息:

PHP Warning:  mysqli_real_connect(): (HY000/2002): No such file or directory 
in /home/matt-j/windows-desktop/projects/wp-rest-api-with-js/wp-includes/wp- 
db.php on line 1531
Warning: mysqli_real_connect(): (HY000/2002): No such file or directory in 
/home/matt-j/windows-desktop/projects/wp-rest-api-with-js/wp-includes/wp- 
db.php on line 1531
Error: Error establishing a database connection. This either means that the 
username and password information in your `wp-config.php` file is incorrect 
or we can’t contact the database server at `localhost`. This could mean your 
host’s database server is down.

我无法让WP-CLI与Windows上的MAMP和Windows上安装在VirtualBox上的Ubuntu一起工作。因此,我:

  • 在Windows上的VirtualBox上的Ubuntu上安装了XAMPP
  • 通过转到
    /opt/lampp/etc/httpd.conf
    并编辑
    httpd.conf
    ,将XAMPP的文档根目录更改为指向我的Windows目录,以便将
    DocumentRoot”/opt/lampp/htdocs“
    目录/opt/lampp/htdocs”
    编辑为
    DocumentRoot”/home/matt-j/Windows desktop/apfm/repos
    ”和
    Directory”/home/matt-j/windows desktop/apfm/repos“
    注意
    windows desktop
    是我在windows 10主机上的桌面的别名)
  • 然后我在我的Ubuntu
    .profile
    文件中添加了以下代码:
  • #定义XAMPP的路径

    XAMPP_路径=/opt/lampp/bin:/opt/lampp/sbin

    export PATH=“$XAMPP\u PATH:$PATH”

  • 然后我通过在Ubuntu终端中执行
    source~/.profile
    重新加载了
    .profile
    文件
  • 最后,我导航到WordPress安装的Ubuntu终端目录(如
    ~/windows desktop/apfm/repos/mj_local_test_wp
    ),并可以成功运行wp CLI命令(如
    wp plugin install jetpack

  • 我希望这对别人有帮助

    它清楚地显示用户名或密码或数据库名称错误这意味着
    wp config.php
    文件中的用户名和密码信息不正确,或者它无法通过
    localhost
    与数据库服务器联系