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时出现同样的错误
更新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