admin管理员组文章数量:1429688
I am new to wordpress but not to programming to please bear with me. I am trying to get a new wordpress project up and running locally using the wp-cli.
But when I run the following command:
wp core install --url=example --title=WP-EXAMPLE --admin_user=******* --admin_password=****** --admin_email=******
I get the following error:
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.
I was able to run the wp config
create and wp db create
commands without issue and a database was create so I know that the database username and password are correct. Is there a step I am missing?
The output of wp --info
is as follows:
OS: Darwin 17.6.0 Darwin Kernel Version 17.6.0: Tue May 8 15:22:16 PDT 2018; root:xnu-4570.61.1~1/RELEASE_X86_64 x86_64
Shell: /bin/zsh
PHP binary: /usr/bin/php
PHP version: 7.1.16
php.ini used:
WP-CLI root dir: phar://wp-cli.phar
WP-CLI vendor dir: phar://wp-cli.phar/vendor
WP_CLI phar path: /Users/admin/code/wp-example
WP-CLI packages dir:
WP-CLI global config:
WP-CLI project config:
WP-CLI version: 1.5.1
Since there are so many blank items I feel as though I am missing something although I have following all of the steps that I have found in quick start guides for setting up wordpress from the CLI.
Thanks in advance.
I am new to wordpress but not to programming to please bear with me. I am trying to get a new wordpress project up and running locally using the wp-cli.
But when I run the following command:
wp core install --url=example --title=WP-EXAMPLE --admin_user=******* --admin_password=****** --admin_email=******
I get the following error:
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.
I was able to run the wp config
create and wp db create
commands without issue and a database was create so I know that the database username and password are correct. Is there a step I am missing?
The output of wp --info
is as follows:
OS: Darwin 17.6.0 Darwin Kernel Version 17.6.0: Tue May 8 15:22:16 PDT 2018; root:xnu-4570.61.1~1/RELEASE_X86_64 x86_64
Shell: /bin/zsh
PHP binary: /usr/bin/php
PHP version: 7.1.16
php.ini used:
WP-CLI root dir: phar://wp-cli.phar
WP-CLI vendor dir: phar://wp-cli.phar/vendor
WP_CLI phar path: /Users/admin/code/wp-example
WP-CLI packages dir:
WP-CLI global config:
WP-CLI project config:
WP-CLI version: 1.5.1
Since there are so many blank items I feel as though I am missing something although I have following all of the steps that I have found in quick start guides for setting up wordpress from the CLI.
Thanks in advance.
Share Improve this question asked Jul 24, 2018 at 19:28 Michael CooleyMichael Cooley 412 bronze badges1 Answer
Reset to default 2First ensure the normal browser install works. If not, here's a really good article on that: How to Fix the Error Establishing a Database Connection in WordPress.
Next thing to note is that your database may not be hosted on localhost
. Then try to create the wp-config.php
using 127.0.0.1
or 127.0.0.1:8889
(for MAMP for example) or something similar. On an existing installation this can be fixed by replacing the DB_HOST
with define('DB_HOST', '127.0.0.1:8889');
in your wp-config.php
.
For an existing site you could also try it with define('WP_ALLOW_REPAIR', true);
in your wp-config.php
and then access the site in a browser to let WordPress fix some common database issues for you.
The article also suggest to create a raw testconnection.php
file in your WordPress root (replaced the database credentials with yours) and call that in a browser http://example/testconnection.php
to see what will be returned:
<?php $link = mysqli_connect('localhost', 'username', 'password'); if (!$link) { die('Could not connect: ' . mysqli_error()); } echo 'Connected successfully'; mysqli_close($link); ?>
本文标签: installationwp core install database connection error
版权声明:本文标题:installation - wp core install database connection error 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745539133a2662409.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论