Local Worpdress website can not connect to its database
up vote
0
down vote
favorite
I am trying to install a Wordpress site on a local server (Ubuntu 16.04 in a docker container).
Xampp is installed and running, and I have created a database and a username with proper rights:
mysql -uroot -e "CREATE USER 'localuser'@'localhost' IDENTIFIED BY 'localpassword';";
mysql -uroot -e 'CREATE DATABASE 'localdatabase';';
mysql -uroot -e "GRANT ALL ON localdatabase.* TO 'localuser'@'localhost';";
I've also updated my wp-config.php file with the credentials above.
Still, when I try to install wordpress from there (I use wp-cli), I get the message "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've double checked the credentials, and xampp is indeed running, so what should I check next? Could this come from a config file that is missing something?
wordpress xampp wp-cli
add a comment |
up vote
0
down vote
favorite
I am trying to install a Wordpress site on a local server (Ubuntu 16.04 in a docker container).
Xampp is installed and running, and I have created a database and a username with proper rights:
mysql -uroot -e "CREATE USER 'localuser'@'localhost' IDENTIFIED BY 'localpassword';";
mysql -uroot -e 'CREATE DATABASE 'localdatabase';';
mysql -uroot -e "GRANT ALL ON localdatabase.* TO 'localuser'@'localhost';";
I've also updated my wp-config.php file with the credentials above.
Still, when I try to install wordpress from there (I use wp-cli), I get the message "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've double checked the credentials, and xampp is indeed running, so what should I check next? Could this come from a config file that is missing something?
wordpress xampp wp-cli
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I am trying to install a Wordpress site on a local server (Ubuntu 16.04 in a docker container).
Xampp is installed and running, and I have created a database and a username with proper rights:
mysql -uroot -e "CREATE USER 'localuser'@'localhost' IDENTIFIED BY 'localpassword';";
mysql -uroot -e 'CREATE DATABASE 'localdatabase';';
mysql -uroot -e "GRANT ALL ON localdatabase.* TO 'localuser'@'localhost';";
I've also updated my wp-config.php file with the credentials above.
Still, when I try to install wordpress from there (I use wp-cli), I get the message "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've double checked the credentials, and xampp is indeed running, so what should I check next? Could this come from a config file that is missing something?
wordpress xampp wp-cli
I am trying to install a Wordpress site on a local server (Ubuntu 16.04 in a docker container).
Xampp is installed and running, and I have created a database and a username with proper rights:
mysql -uroot -e "CREATE USER 'localuser'@'localhost' IDENTIFIED BY 'localpassword';";
mysql -uroot -e 'CREATE DATABASE 'localdatabase';';
mysql -uroot -e "GRANT ALL ON localdatabase.* TO 'localuser'@'localhost';";
I've also updated my wp-config.php file with the credentials above.
Still, when I try to install wordpress from there (I use wp-cli), I get the message "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've double checked the credentials, and xampp is indeed running, so what should I check next? Could this come from a config file that is missing something?
wordpress xampp wp-cli
wordpress xampp wp-cli
asked Nov 10 at 16:02
Sulli
170218
170218
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
up vote
0
down vote
What hostname are you using in the wp-config? Also did the commands finish succesfully? For creating the db you used apostrophes instead of quotes. You can try the mysql client directly with mysql -u -p -h .
New contributor
I'm using 'localhost' in wp-config.php. Yes the commands finish successfully. I checked with SHOW DATABASES; and SHOW GRANTS; , my database has been created, my username too and the username has the rights
– Sulli
Nov 10 at 20:23
Is the mysql in the same container as wordpress? If so you cannot use localhost, you have to use the ip of the musql container.
– Andrei Dumitrescu-Tudor
Nov 10 at 20:25
yes they are in the same container. You're saying I can not use localhost in this case?
– Sulli
Nov 10 at 20:42
If they are in the same container you can use localhost. I mistyped before.
– Andrei Dumitrescu-Tudor
Nov 10 at 20:46
ah ok that's what I thought. I added the -p 4000:80 option for my docker and tried to access in my host's browser localhost:4000/phpmyadmin, but got the error "Access forbidden! New XAMPP security concept: Access to the requested directory is only available from the local network.This setting can be configured in the file "httpd-xampp.conf"." Is this related to my issue or is it only a because I'm accessing phpmyadmin from the host?
– Sulli
Nov 10 at 21:04
|
show 1 more comment
up vote
0
down vote
In wp-config.php, use 127.0.0.1 instead of localhost for the database hostname.
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
What hostname are you using in the wp-config? Also did the commands finish succesfully? For creating the db you used apostrophes instead of quotes. You can try the mysql client directly with mysql -u -p -h .
New contributor
I'm using 'localhost' in wp-config.php. Yes the commands finish successfully. I checked with SHOW DATABASES; and SHOW GRANTS; , my database has been created, my username too and the username has the rights
– Sulli
Nov 10 at 20:23
Is the mysql in the same container as wordpress? If so you cannot use localhost, you have to use the ip of the musql container.
– Andrei Dumitrescu-Tudor
Nov 10 at 20:25
yes they are in the same container. You're saying I can not use localhost in this case?
– Sulli
Nov 10 at 20:42
If they are in the same container you can use localhost. I mistyped before.
– Andrei Dumitrescu-Tudor
Nov 10 at 20:46
ah ok that's what I thought. I added the -p 4000:80 option for my docker and tried to access in my host's browser localhost:4000/phpmyadmin, but got the error "Access forbidden! New XAMPP security concept: Access to the requested directory is only available from the local network.This setting can be configured in the file "httpd-xampp.conf"." Is this related to my issue or is it only a because I'm accessing phpmyadmin from the host?
– Sulli
Nov 10 at 21:04
|
show 1 more comment
up vote
0
down vote
What hostname are you using in the wp-config? Also did the commands finish succesfully? For creating the db you used apostrophes instead of quotes. You can try the mysql client directly with mysql -u -p -h .
New contributor
I'm using 'localhost' in wp-config.php. Yes the commands finish successfully. I checked with SHOW DATABASES; and SHOW GRANTS; , my database has been created, my username too and the username has the rights
– Sulli
Nov 10 at 20:23
Is the mysql in the same container as wordpress? If so you cannot use localhost, you have to use the ip of the musql container.
– Andrei Dumitrescu-Tudor
Nov 10 at 20:25
yes they are in the same container. You're saying I can not use localhost in this case?
– Sulli
Nov 10 at 20:42
If they are in the same container you can use localhost. I mistyped before.
– Andrei Dumitrescu-Tudor
Nov 10 at 20:46
ah ok that's what I thought. I added the -p 4000:80 option for my docker and tried to access in my host's browser localhost:4000/phpmyadmin, but got the error "Access forbidden! New XAMPP security concept: Access to the requested directory is only available from the local network.This setting can be configured in the file "httpd-xampp.conf"." Is this related to my issue or is it only a because I'm accessing phpmyadmin from the host?
– Sulli
Nov 10 at 21:04
|
show 1 more comment
up vote
0
down vote
up vote
0
down vote
What hostname are you using in the wp-config? Also did the commands finish succesfully? For creating the db you used apostrophes instead of quotes. You can try the mysql client directly with mysql -u -p -h .
New contributor
What hostname are you using in the wp-config? Also did the commands finish succesfully? For creating the db you used apostrophes instead of quotes. You can try the mysql client directly with mysql -u -p -h .
New contributor
New contributor
answered Nov 10 at 16:13
Andrei Dumitrescu-Tudor
874
874
New contributor
New contributor
I'm using 'localhost' in wp-config.php. Yes the commands finish successfully. I checked with SHOW DATABASES; and SHOW GRANTS; , my database has been created, my username too and the username has the rights
– Sulli
Nov 10 at 20:23
Is the mysql in the same container as wordpress? If so you cannot use localhost, you have to use the ip of the musql container.
– Andrei Dumitrescu-Tudor
Nov 10 at 20:25
yes they are in the same container. You're saying I can not use localhost in this case?
– Sulli
Nov 10 at 20:42
If they are in the same container you can use localhost. I mistyped before.
– Andrei Dumitrescu-Tudor
Nov 10 at 20:46
ah ok that's what I thought. I added the -p 4000:80 option for my docker and tried to access in my host's browser localhost:4000/phpmyadmin, but got the error "Access forbidden! New XAMPP security concept: Access to the requested directory is only available from the local network.This setting can be configured in the file "httpd-xampp.conf"." Is this related to my issue or is it only a because I'm accessing phpmyadmin from the host?
– Sulli
Nov 10 at 21:04
|
show 1 more comment
I'm using 'localhost' in wp-config.php. Yes the commands finish successfully. I checked with SHOW DATABASES; and SHOW GRANTS; , my database has been created, my username too and the username has the rights
– Sulli
Nov 10 at 20:23
Is the mysql in the same container as wordpress? If so you cannot use localhost, you have to use the ip of the musql container.
– Andrei Dumitrescu-Tudor
Nov 10 at 20:25
yes they are in the same container. You're saying I can not use localhost in this case?
– Sulli
Nov 10 at 20:42
If they are in the same container you can use localhost. I mistyped before.
– Andrei Dumitrescu-Tudor
Nov 10 at 20:46
ah ok that's what I thought. I added the -p 4000:80 option for my docker and tried to access in my host's browser localhost:4000/phpmyadmin, but got the error "Access forbidden! New XAMPP security concept: Access to the requested directory is only available from the local network.This setting can be configured in the file "httpd-xampp.conf"." Is this related to my issue or is it only a because I'm accessing phpmyadmin from the host?
– Sulli
Nov 10 at 21:04
I'm using 'localhost' in wp-config.php. Yes the commands finish successfully. I checked with SHOW DATABASES; and SHOW GRANTS; , my database has been created, my username too and the username has the rights
– Sulli
Nov 10 at 20:23
I'm using 'localhost' in wp-config.php. Yes the commands finish successfully. I checked with SHOW DATABASES; and SHOW GRANTS; , my database has been created, my username too and the username has the rights
– Sulli
Nov 10 at 20:23
Is the mysql in the same container as wordpress? If so you cannot use localhost, you have to use the ip of the musql container.
– Andrei Dumitrescu-Tudor
Nov 10 at 20:25
Is the mysql in the same container as wordpress? If so you cannot use localhost, you have to use the ip of the musql container.
– Andrei Dumitrescu-Tudor
Nov 10 at 20:25
yes they are in the same container. You're saying I can not use localhost in this case?
– Sulli
Nov 10 at 20:42
yes they are in the same container. You're saying I can not use localhost in this case?
– Sulli
Nov 10 at 20:42
If they are in the same container you can use localhost. I mistyped before.
– Andrei Dumitrescu-Tudor
Nov 10 at 20:46
If they are in the same container you can use localhost. I mistyped before.
– Andrei Dumitrescu-Tudor
Nov 10 at 20:46
ah ok that's what I thought. I added the -p 4000:80 option for my docker and tried to access in my host's browser localhost:4000/phpmyadmin, but got the error "Access forbidden! New XAMPP security concept: Access to the requested directory is only available from the local network.This setting can be configured in the file "httpd-xampp.conf"." Is this related to my issue or is it only a because I'm accessing phpmyadmin from the host?
– Sulli
Nov 10 at 21:04
ah ok that's what I thought. I added the -p 4000:80 option for my docker and tried to access in my host's browser localhost:4000/phpmyadmin, but got the error "Access forbidden! New XAMPP security concept: Access to the requested directory is only available from the local network.This setting can be configured in the file "httpd-xampp.conf"." Is this related to my issue or is it only a because I'm accessing phpmyadmin from the host?
– Sulli
Nov 10 at 21:04
|
show 1 more comment
up vote
0
down vote
In wp-config.php, use 127.0.0.1 instead of localhost for the database hostname.
add a comment |
up vote
0
down vote
In wp-config.php, use 127.0.0.1 instead of localhost for the database hostname.
add a comment |
up vote
0
down vote
up vote
0
down vote
In wp-config.php, use 127.0.0.1 instead of localhost for the database hostname.
In wp-config.php, use 127.0.0.1 instead of localhost for the database hostname.
answered Nov 10 at 21:40
Sulli
170218
170218
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53240752%2flocal-worpdress-website-can-not-connect-to-its-database%23new-answer', 'question_page');
}
);
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password