加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

bash – wp-cli:无法在MAMP上运行phpunit

发布时间:2020-12-15 18:52:13 所属栏目:安全 来源:网络整理
导读:我跟着 plugin test setup/install instructions.我得到了wp脚本插件测试我的插件来运行.但是在下一步当我尝试运行bash bin / install-wp-tests.sh wordpress_test root”localhost最新我收到以下错误: mysqladmin: connect to server at 'localhost' faile
我跟着 plugin test setup/install instructions.我得到了wp脚本插件测试我的插件来运行.但是在下一步当我尝试运行bash bin / install-wp-tests.sh wordpress_test root”localhost最新我收到以下错误:
mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to MySQL server on 'localhost' (61)'
Check that mysqld is running on localhost and that the port is 3306.
You can check this by doing 'telnet localhost 3306'

我的本地Wordpress网站正在运行MAMP(正在工作).我不知道这是否与安装脚本相关,因为我认为它正在创建一个临时数据库来运行测试…如果它使用内置的OSX或MySQL的MySQL?

这是wp –info的输出

$./vendor/wp-cli/wp-cli/bin/wp --info
PHP binary: /Applications/MAMP/bin/php/php5.6.10/bin/php
PHP version:    5.6.10
php.ini used:   /Applications/MAMP/bin/php/php5.6.10/conf/php.ini
WP-CLI root dir:    /Applications/MAMP/htdocs/pipeline/wp-content/plugins/wp-github-pipeline/vendor/wp-cli/wp-cli
WP-CLI global config:   
WP-CLI project config:  
WP-CLI version: 0.19.2

更新2
我发现原来MySQL没有安装…这就是为什么我无法连接!但现在是.我运行安装脚本,这是工作…

$./vendor/wp-cli/wp-cli/bin/wp db tables
wp_users
wp_usermeta
wp_posts
wp_comments
wp_links
wp_options
wp_postmeta
wp_terms
wp_term_taxonomy
wp_term_relationships
wp_commentmeta

但是当我运行phpunit我得到这个:

$phpunit
PHP Warning:  mysqli_real_connect(): (HY000/2002): No such file or directory in /private/tmp/wordpress/wp-includes/wp-db.php on line 1452
PHP Stack trace:
PHP   1. {main}() /private/tmp/wordpress-tests-lib/includes/install.php:0
PHP   2. require_once() /private/tmp/wordpress-tests-lib/includes/install.php:21
PHP   3. require_wp_db() /private/tmp/wordpress/wp-settings.php:79
PHP   4. wpdb->__construct() /private/tmp/wordpress/wp-includes/load.php:350
PHP   5. wpdb->db_connect() /private/tmp/wordpress/wp-includes/wp-db.php:649
PHP   6. mysqli_real_connect() /private/tmp/wordpress/wp-includes/wp-db.php:1452

Warning: mysqli_real_connect(): (HY000/2002): No such file or directory in /private/tmp/wordpress/wp-includes/wp-db.php on line 1452

我的问题的一部分是,我不清楚是否wp-cli应该完全运行在native(cli)PHP / Mysql或MAMP的PHP / Mysql,或两者的某种组合.

更新4
我确定最后的问题是phpunit需要安装在MAMP中,但是我正在从OSX运行…

$which phpunit
/usr/bin/phpunit

在this gist提到.

更新6

原来你不能再使用梨来安装phpunit了.所以我把它作为一个作曲家依赖在require-dev,但是当我运行那个版本我得到相同的错误!

$./vendor/phpunit/phpunit/phpunit
PHP Warning:  mysqli_real_connect(): (HY000/1045): Access denied for user 'root'@'localhost' (using password: NO) in /private/tmp/wordpress/wp-includes/wp-db.php on line 1452
PHP Stack trace:
PHP   1. {main}() /private/tmp/wordpress-tests-lib/includes/install.php:0
PHP   2. require_once() /private/tmp/wordpress-tests-lib/includes/install.php:21
PHP   3. require_wp_db() /private/tmp/wordpress/wp-settings.php:79
PHP   4. wpdb->__construct() /private/tmp/wordpress/wp-includes/load.php:350
PHP   5. wpdb->db_connect() /private/tmp/wordpress/wp-includes/wp-db.php:649
PHP   6. mysqli_real_connect() /private/tmp/wordpress/wp-includes/wp-db.php:1452

Warning: mysqli_real_connect(): (HY000/1045): Access denied for user 'root'@'localhost' (using password: NO) in /private/tmp/wordpress/wp-includes/wp-db.php on line 1452

我甚至把它添加到我的路上,以确保…

$which phpunit
/Applications/MAMP/htdocs/pipeline/wp-content/plugins/wp-github-pipeline/vendor/phpunit/phpunit/phpunit

更新7

阅读this博客文章底部的评论后,我看到安装脚本引用了OSX版本的mysqladmin.我不知道这是否重要,但我在路径中添加了MAMPs版本,并重新运行安装脚本.似乎在/ tmp / anyway中安装Wordpress文件.运行phpunit时出现同样的错误

如果您使用MAMP,问题可能与您的MySQL服务器设置相关.确保在MAMP设置中选中允许网络访问选项:

更新1

在根目录中创建phpinfo.php文件(通常是/ Applications / MAMP / htdocs for MAMP).粘贴以下内容:

<?php phpinfo() ?>

然后检查加载的配置文件属性.在终端中使用nano或其他文本编辑器打开它.然后找到并将此3 propertiespdo_mysql.default_socket,mysql.default_socket,mysqli.default_socket更改为您的套接字文件.

参考http://maccrazy.com/lion-upgrade-killed-my-php-site-and-how-i-fixed-it

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读