【问题标题】:Can't Install Plugins with WP CLI无法使用 WP CLI 安装插件
【发布时间】:2018-07-28 02:13:38
【问题描述】:

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

我在 Windows 10 上使用 MAMP 运行本地 WordPress 站点。我在 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-config.php 文件中的用户名和密码信息不正确,要么它无法联系localhost 的数据库服务器

标签: wordpress


【解决方案1】:

我无法让 WP-CLI 与 Windows 上的 MAMP 和安装在 Windows 上的 VirtualBox 上的 Ubuntu 一起工作。所以我改为:

  1. 在 Ubuntu 上安装了 XAMPP,该 XAMPP 在 Windows 上的 VirtualBox 上运行。
  2. 将 XAMPP 的文档根目录更改为指向我的 Windows 目录,方法是转到 /opt/lampp/etc/httpd.conf 并编辑 httpd.conf,以便将 DocumentRoot "/opt/lampp/htdocs"Directory "/opt/lampp/htdocs" 编辑为 DocumentRoot "/home/matt-j/windows-desktop/apfm/repos" 和 Directory "/home/matt-j/windows-desktop/apfm/repos" (注意windows-desktop 是我在 Windows 10 主机上的桌面的别名。
  3. 然后我在我的 Ubuntu .profile 文件中添加了以下代码:

# Define path for XAMPP

XAMPP_PATH=/opt/lampp/bin:/opt/lampp/sbin

export PATH="$XAMPP_PATH:$PATH"

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

我希望这对某人有帮助!

【讨论】:

    猜你喜欢
    • 2017-05-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-08-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多