WordPress Error establishing a MySQL database connection IIS10 [duplicate]
This question already has an answer here:
PDO::__construct(): Server sent charset (255) unknown to the client. Please, report to the developers
5 answers
Wordpress cannot connect to mysql server
6 answers
I'm trying to setup WordPress with MySQL on my local Windows 10 machine.
I'm getting this 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:3307. This could mean your host's database server is down.
I already checked here: Error establishing a database connection on wordpress
- Are you sure you have the correct username and password?
Yes, I can login to SQL Server Workbench with theroot
credentials, so that is working - Are you sure that you have typed the correct hostname?
That's what I'm trying below - Are you sure that the database server is running?
Yes, checked in MySQL workbench and it's running
I ran this query select @@hostname
which gives me: DESKTOP-CFT2ESY
I tried adding to wp-config.php (not all at the same time):
define('DB_HOST', 'localhost:3307');
define('DB_HOST', 'localhost:8899');
define('DB_HOST', 'localhost');
define('DB_HOST', 'DESKTOP-CFT2ESY');
define('DB_HOST', '127.0.0.1');
None of these work, it just changes the hostname string in the above error message.
I then added:define('WP_ALLOW_REPAIR', true);
define('DB_CHARSET', 'utf8');
But that does not change the error message at all.
UPDATE 1
I ran SHOW GLOBAL VARIABLES LIKE 'PORT';
and my server runs on port 3306. In WorkBench I see my database is up and running.
I also added all privileges for user root
on my database schema. My user's Limit to hosts matching
is set to localhost
.
UPDATE 2
I then ran this PHP code which I found here (I just changed the root user's password to my root user's password):
<?php
$host="localhost";
$root="root";
$root_password="rootpass";
$user='newuser';
$pass='newpass';
$db="newdb";
try {
$dbh = new PDO("mysql:host=$host", $root, $root_password);
$dbh->exec("CREATE DATABASE `$db`;
CREATE USER '$user'@'localhost' IDENTIFIED BY '$pass';
GRANT ALL ON `$db`.* TO '$user'@'localhost';
FLUSH PRIVILEGES;")
or die(print_r($dbh->errorInfo(), true));
} catch (PDOException $e) {
die("DB ERROR: ". $e->getMessage());
}
?>
But this trows the error:
DB ERROR: SQLSTATE[HY000] [2054] Server sent charset unknown to the client. Please, report to the developers
UPDATE 3
I then ran query: SELECT default_character_set_name FROM information_schema.SCHEMATA S WHERE schema_name = "myDB";
which returns utf8
, so the same character set as defined in my wp-config.php
.
UPDATE 4
I checked here. I just had a mysqlrouter.conf.sample
in my C:Program FilesMySQLMySQL Server 8.0etc
folder, so I added a my.cnf
file with:
[client]
default-character-set=utf8
[mysql]
default-character-set=utf8
[mysqld]
collation-server = utf8_unicode_ci
init-connect='SET NAMES utf8'
character-set-server = utf8
I restarted the MySQL windows service but the error remains the same.
What else can I try?
php mysql wordpress iis-10 mysql-8.0
marked as duplicate by Cody Gray♦ Mar 23 at 22:39
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
|
show 12 more comments
This question already has an answer here:
PDO::__construct(): Server sent charset (255) unknown to the client. Please, report to the developers
5 answers
Wordpress cannot connect to mysql server
6 answers
I'm trying to setup WordPress with MySQL on my local Windows 10 machine.
I'm getting this 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:3307. This could mean your host's database server is down.
I already checked here: Error establishing a database connection on wordpress
- Are you sure you have the correct username and password?
Yes, I can login to SQL Server Workbench with theroot
credentials, so that is working - Are you sure that you have typed the correct hostname?
That's what I'm trying below - Are you sure that the database server is running?
Yes, checked in MySQL workbench and it's running
I ran this query select @@hostname
which gives me: DESKTOP-CFT2ESY
I tried adding to wp-config.php (not all at the same time):
define('DB_HOST', 'localhost:3307');
define('DB_HOST', 'localhost:8899');
define('DB_HOST', 'localhost');
define('DB_HOST', 'DESKTOP-CFT2ESY');
define('DB_HOST', '127.0.0.1');
None of these work, it just changes the hostname string in the above error message.
I then added:define('WP_ALLOW_REPAIR', true);
define('DB_CHARSET', 'utf8');
But that does not change the error message at all.
UPDATE 1
I ran SHOW GLOBAL VARIABLES LIKE 'PORT';
and my server runs on port 3306. In WorkBench I see my database is up and running.
I also added all privileges for user root
on my database schema. My user's Limit to hosts matching
is set to localhost
.
UPDATE 2
I then ran this PHP code which I found here (I just changed the root user's password to my root user's password):
<?php
$host="localhost";
$root="root";
$root_password="rootpass";
$user='newuser';
$pass='newpass';
$db="newdb";
try {
$dbh = new PDO("mysql:host=$host", $root, $root_password);
$dbh->exec("CREATE DATABASE `$db`;
CREATE USER '$user'@'localhost' IDENTIFIED BY '$pass';
GRANT ALL ON `$db`.* TO '$user'@'localhost';
FLUSH PRIVILEGES;")
or die(print_r($dbh->errorInfo(), true));
} catch (PDOException $e) {
die("DB ERROR: ". $e->getMessage());
}
?>
But this trows the error:
DB ERROR: SQLSTATE[HY000] [2054] Server sent charset unknown to the client. Please, report to the developers
UPDATE 3
I then ran query: SELECT default_character_set_name FROM information_schema.SCHEMATA S WHERE schema_name = "myDB";
which returns utf8
, so the same character set as defined in my wp-config.php
.
UPDATE 4
I checked here. I just had a mysqlrouter.conf.sample
in my C:Program FilesMySQLMySQL Server 8.0etc
folder, so I added a my.cnf
file with:
[client]
default-character-set=utf8
[mysql]
default-character-set=utf8
[mysqld]
collation-server = utf8_unicode_ci
init-connect='SET NAMES utf8'
character-set-server = utf8
I restarted the MySQL windows service but the error remains the same.
What else can I try?
php mysql wordpress iis-10 mysql-8.0
marked as duplicate by Cody Gray♦ Mar 23 at 22:39
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
1
Your host does not seem to be the problem ... leave it to localhost. Make sure DB_NAME, DB_USER, DB_PASSWORD is well defined. Maby a type in one of them?
– Patrick Simard
Dec 30 '18 at 16:41
You keep overwriting those, so only the last one takes effect.
– Funk Forty Niner
Dec 30 '18 at 16:47
1
Lol i am pretty sure he was just listing what he tryed
– Patrick Simard
Dec 30 '18 at 16:49
@PatrickSimard: I was indeed listing what I tried :-), I also rechecked name/user/password and literally copied them in workbench to test and it works there, so no typos. What else could it be? I'm running MySQL as a Windows service if that matters.
– Flo
Dec 31 '18 at 15:26
1
this help: stackoverflow.com/questions/43437490/… ?
– treyBake
Jan 2 at 14:43
|
show 12 more comments
This question already has an answer here:
PDO::__construct(): Server sent charset (255) unknown to the client. Please, report to the developers
5 answers
Wordpress cannot connect to mysql server
6 answers
I'm trying to setup WordPress with MySQL on my local Windows 10 machine.
I'm getting this 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:3307. This could mean your host's database server is down.
I already checked here: Error establishing a database connection on wordpress
- Are you sure you have the correct username and password?
Yes, I can login to SQL Server Workbench with theroot
credentials, so that is working - Are you sure that you have typed the correct hostname?
That's what I'm trying below - Are you sure that the database server is running?
Yes, checked in MySQL workbench and it's running
I ran this query select @@hostname
which gives me: DESKTOP-CFT2ESY
I tried adding to wp-config.php (not all at the same time):
define('DB_HOST', 'localhost:3307');
define('DB_HOST', 'localhost:8899');
define('DB_HOST', 'localhost');
define('DB_HOST', 'DESKTOP-CFT2ESY');
define('DB_HOST', '127.0.0.1');
None of these work, it just changes the hostname string in the above error message.
I then added:define('WP_ALLOW_REPAIR', true);
define('DB_CHARSET', 'utf8');
But that does not change the error message at all.
UPDATE 1
I ran SHOW GLOBAL VARIABLES LIKE 'PORT';
and my server runs on port 3306. In WorkBench I see my database is up and running.
I also added all privileges for user root
on my database schema. My user's Limit to hosts matching
is set to localhost
.
UPDATE 2
I then ran this PHP code which I found here (I just changed the root user's password to my root user's password):
<?php
$host="localhost";
$root="root";
$root_password="rootpass";
$user='newuser';
$pass='newpass';
$db="newdb";
try {
$dbh = new PDO("mysql:host=$host", $root, $root_password);
$dbh->exec("CREATE DATABASE `$db`;
CREATE USER '$user'@'localhost' IDENTIFIED BY '$pass';
GRANT ALL ON `$db`.* TO '$user'@'localhost';
FLUSH PRIVILEGES;")
or die(print_r($dbh->errorInfo(), true));
} catch (PDOException $e) {
die("DB ERROR: ". $e->getMessage());
}
?>
But this trows the error:
DB ERROR: SQLSTATE[HY000] [2054] Server sent charset unknown to the client. Please, report to the developers
UPDATE 3
I then ran query: SELECT default_character_set_name FROM information_schema.SCHEMATA S WHERE schema_name = "myDB";
which returns utf8
, so the same character set as defined in my wp-config.php
.
UPDATE 4
I checked here. I just had a mysqlrouter.conf.sample
in my C:Program FilesMySQLMySQL Server 8.0etc
folder, so I added a my.cnf
file with:
[client]
default-character-set=utf8
[mysql]
default-character-set=utf8
[mysqld]
collation-server = utf8_unicode_ci
init-connect='SET NAMES utf8'
character-set-server = utf8
I restarted the MySQL windows service but the error remains the same.
What else can I try?
php mysql wordpress iis-10 mysql-8.0
This question already has an answer here:
PDO::__construct(): Server sent charset (255) unknown to the client. Please, report to the developers
5 answers
Wordpress cannot connect to mysql server
6 answers
I'm trying to setup WordPress with MySQL on my local Windows 10 machine.
I'm getting this 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:3307. This could mean your host's database server is down.
I already checked here: Error establishing a database connection on wordpress
- Are you sure you have the correct username and password?
Yes, I can login to SQL Server Workbench with theroot
credentials, so that is working - Are you sure that you have typed the correct hostname?
That's what I'm trying below - Are you sure that the database server is running?
Yes, checked in MySQL workbench and it's running
I ran this query select @@hostname
which gives me: DESKTOP-CFT2ESY
I tried adding to wp-config.php (not all at the same time):
define('DB_HOST', 'localhost:3307');
define('DB_HOST', 'localhost:8899');
define('DB_HOST', 'localhost');
define('DB_HOST', 'DESKTOP-CFT2ESY');
define('DB_HOST', '127.0.0.1');
None of these work, it just changes the hostname string in the above error message.
I then added:define('WP_ALLOW_REPAIR', true);
define('DB_CHARSET', 'utf8');
But that does not change the error message at all.
UPDATE 1
I ran SHOW GLOBAL VARIABLES LIKE 'PORT';
and my server runs on port 3306. In WorkBench I see my database is up and running.
I also added all privileges for user root
on my database schema. My user's Limit to hosts matching
is set to localhost
.
UPDATE 2
I then ran this PHP code which I found here (I just changed the root user's password to my root user's password):
<?php
$host="localhost";
$root="root";
$root_password="rootpass";
$user='newuser';
$pass='newpass';
$db="newdb";
try {
$dbh = new PDO("mysql:host=$host", $root, $root_password);
$dbh->exec("CREATE DATABASE `$db`;
CREATE USER '$user'@'localhost' IDENTIFIED BY '$pass';
GRANT ALL ON `$db`.* TO '$user'@'localhost';
FLUSH PRIVILEGES;")
or die(print_r($dbh->errorInfo(), true));
} catch (PDOException $e) {
die("DB ERROR: ". $e->getMessage());
}
?>
But this trows the error:
DB ERROR: SQLSTATE[HY000] [2054] Server sent charset unknown to the client. Please, report to the developers
UPDATE 3
I then ran query: SELECT default_character_set_name FROM information_schema.SCHEMATA S WHERE schema_name = "myDB";
which returns utf8
, so the same character set as defined in my wp-config.php
.
UPDATE 4
I checked here. I just had a mysqlrouter.conf.sample
in my C:Program FilesMySQLMySQL Server 8.0etc
folder, so I added a my.cnf
file with:
[client]
default-character-set=utf8
[mysql]
default-character-set=utf8
[mysqld]
collation-server = utf8_unicode_ci
init-connect='SET NAMES utf8'
character-set-server = utf8
I restarted the MySQL windows service but the error remains the same.
What else can I try?
This question already has an answer here:
PDO::__construct(): Server sent charset (255) unknown to the client. Please, report to the developers
5 answers
Wordpress cannot connect to mysql server
6 answers
php mysql wordpress iis-10 mysql-8.0
php mysql wordpress iis-10 mysql-8.0
edited Jan 2 at 17:12
Flo
asked Dec 30 '18 at 16:35


FloFlo
2,8792179148
2,8792179148
marked as duplicate by Cody Gray♦ Mar 23 at 22:39
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by Cody Gray♦ Mar 23 at 22:39
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
1
Your host does not seem to be the problem ... leave it to localhost. Make sure DB_NAME, DB_USER, DB_PASSWORD is well defined. Maby a type in one of them?
– Patrick Simard
Dec 30 '18 at 16:41
You keep overwriting those, so only the last one takes effect.
– Funk Forty Niner
Dec 30 '18 at 16:47
1
Lol i am pretty sure he was just listing what he tryed
– Patrick Simard
Dec 30 '18 at 16:49
@PatrickSimard: I was indeed listing what I tried :-), I also rechecked name/user/password and literally copied them in workbench to test and it works there, so no typos. What else could it be? I'm running MySQL as a Windows service if that matters.
– Flo
Dec 31 '18 at 15:26
1
this help: stackoverflow.com/questions/43437490/… ?
– treyBake
Jan 2 at 14:43
|
show 12 more comments
1
Your host does not seem to be the problem ... leave it to localhost. Make sure DB_NAME, DB_USER, DB_PASSWORD is well defined. Maby a type in one of them?
– Patrick Simard
Dec 30 '18 at 16:41
You keep overwriting those, so only the last one takes effect.
– Funk Forty Niner
Dec 30 '18 at 16:47
1
Lol i am pretty sure he was just listing what he tryed
– Patrick Simard
Dec 30 '18 at 16:49
@PatrickSimard: I was indeed listing what I tried :-), I also rechecked name/user/password and literally copied them in workbench to test and it works there, so no typos. What else could it be? I'm running MySQL as a Windows service if that matters.
– Flo
Dec 31 '18 at 15:26
1
this help: stackoverflow.com/questions/43437490/… ?
– treyBake
Jan 2 at 14:43
1
1
Your host does not seem to be the problem ... leave it to localhost. Make sure DB_NAME, DB_USER, DB_PASSWORD is well defined. Maby a type in one of them?
– Patrick Simard
Dec 30 '18 at 16:41
Your host does not seem to be the problem ... leave it to localhost. Make sure DB_NAME, DB_USER, DB_PASSWORD is well defined. Maby a type in one of them?
– Patrick Simard
Dec 30 '18 at 16:41
You keep overwriting those, so only the last one takes effect.
– Funk Forty Niner
Dec 30 '18 at 16:47
You keep overwriting those, so only the last one takes effect.
– Funk Forty Niner
Dec 30 '18 at 16:47
1
1
Lol i am pretty sure he was just listing what he tryed
– Patrick Simard
Dec 30 '18 at 16:49
Lol i am pretty sure he was just listing what he tryed
– Patrick Simard
Dec 30 '18 at 16:49
@PatrickSimard: I was indeed listing what I tried :-), I also rechecked name/user/password and literally copied them in workbench to test and it works there, so no typos. What else could it be? I'm running MySQL as a Windows service if that matters.
– Flo
Dec 31 '18 at 15:26
@PatrickSimard: I was indeed listing what I tried :-), I also rechecked name/user/password and literally copied them in workbench to test and it works there, so no typos. What else could it be? I'm running MySQL as a Windows service if that matters.
– Flo
Dec 31 '18 at 15:26
1
1
this help: stackoverflow.com/questions/43437490/… ?
– treyBake
Jan 2 at 14:43
this help: stackoverflow.com/questions/43437490/… ?
– treyBake
Jan 2 at 14:43
|
show 12 more comments
2 Answers
2
active
oldest
votes
As commented by @treyBake please see here.
Basically MySQL 8 changed the default charset to utfmb4 and there are now errors with some clients. I downgraded to MySQL Server 5.6 and the problem is gone.
add a comment |
Look here for the potential solution:
PDO::__construct(): Server sent charset (255) unknown to the client. Please, report to the developers
In essence, you have to make sure that both the DB and the script uses the same charset, preferably utf-8
UPDATE:
See also this:http://php.net/manual/en/mysqli.set-charset.php
I suggest to leave wp alone and try to troubleshoot the problem with the standalone script. Have you checked you MySQL connection charset?
– Eriks Klotins
Jan 2 at 14:40
That is what I tried under update 3 right? It says utf8 already.
– Flo
Jan 2 at 14:41
I am not sure how exactly the wp-config handles charsets. That is why I suggested working with the standalone script where you have full control. Importantly, the script charset, the connection charset, and the DB charset have to be the same for things to work.
– Eriks Klotins
Jan 2 at 14:44
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
As commented by @treyBake please see here.
Basically MySQL 8 changed the default charset to utfmb4 and there are now errors with some clients. I downgraded to MySQL Server 5.6 and the problem is gone.
add a comment |
As commented by @treyBake please see here.
Basically MySQL 8 changed the default charset to utfmb4 and there are now errors with some clients. I downgraded to MySQL Server 5.6 and the problem is gone.
add a comment |
As commented by @treyBake please see here.
Basically MySQL 8 changed the default charset to utfmb4 and there are now errors with some clients. I downgraded to MySQL Server 5.6 and the problem is gone.
As commented by @treyBake please see here.
Basically MySQL 8 changed the default charset to utfmb4 and there are now errors with some clients. I downgraded to MySQL Server 5.6 and the problem is gone.
answered Jan 3 at 14:34


FloFlo
2,8792179148
2,8792179148
add a comment |
add a comment |
Look here for the potential solution:
PDO::__construct(): Server sent charset (255) unknown to the client. Please, report to the developers
In essence, you have to make sure that both the DB and the script uses the same charset, preferably utf-8
UPDATE:
See also this:http://php.net/manual/en/mysqli.set-charset.php
I suggest to leave wp alone and try to troubleshoot the problem with the standalone script. Have you checked you MySQL connection charset?
– Eriks Klotins
Jan 2 at 14:40
That is what I tried under update 3 right? It says utf8 already.
– Flo
Jan 2 at 14:41
I am not sure how exactly the wp-config handles charsets. That is why I suggested working with the standalone script where you have full control. Importantly, the script charset, the connection charset, and the DB charset have to be the same for things to work.
– Eriks Klotins
Jan 2 at 14:44
add a comment |
Look here for the potential solution:
PDO::__construct(): Server sent charset (255) unknown to the client. Please, report to the developers
In essence, you have to make sure that both the DB and the script uses the same charset, preferably utf-8
UPDATE:
See also this:http://php.net/manual/en/mysqli.set-charset.php
I suggest to leave wp alone and try to troubleshoot the problem with the standalone script. Have you checked you MySQL connection charset?
– Eriks Klotins
Jan 2 at 14:40
That is what I tried under update 3 right? It says utf8 already.
– Flo
Jan 2 at 14:41
I am not sure how exactly the wp-config handles charsets. That is why I suggested working with the standalone script where you have full control. Importantly, the script charset, the connection charset, and the DB charset have to be the same for things to work.
– Eriks Klotins
Jan 2 at 14:44
add a comment |
Look here for the potential solution:
PDO::__construct(): Server sent charset (255) unknown to the client. Please, report to the developers
In essence, you have to make sure that both the DB and the script uses the same charset, preferably utf-8
UPDATE:
See also this:http://php.net/manual/en/mysqli.set-charset.php
Look here for the potential solution:
PDO::__construct(): Server sent charset (255) unknown to the client. Please, report to the developers
In essence, you have to make sure that both the DB and the script uses the same charset, preferably utf-8
UPDATE:
See also this:http://php.net/manual/en/mysqli.set-charset.php
edited Jan 2 at 14:40
answered Jan 2 at 14:16
Eriks KlotinsEriks Klotins
1,4181518
1,4181518
I suggest to leave wp alone and try to troubleshoot the problem with the standalone script. Have you checked you MySQL connection charset?
– Eriks Klotins
Jan 2 at 14:40
That is what I tried under update 3 right? It says utf8 already.
– Flo
Jan 2 at 14:41
I am not sure how exactly the wp-config handles charsets. That is why I suggested working with the standalone script where you have full control. Importantly, the script charset, the connection charset, and the DB charset have to be the same for things to work.
– Eriks Klotins
Jan 2 at 14:44
add a comment |
I suggest to leave wp alone and try to troubleshoot the problem with the standalone script. Have you checked you MySQL connection charset?
– Eriks Klotins
Jan 2 at 14:40
That is what I tried under update 3 right? It says utf8 already.
– Flo
Jan 2 at 14:41
I am not sure how exactly the wp-config handles charsets. That is why I suggested working with the standalone script where you have full control. Importantly, the script charset, the connection charset, and the DB charset have to be the same for things to work.
– Eriks Klotins
Jan 2 at 14:44
I suggest to leave wp alone and try to troubleshoot the problem with the standalone script. Have you checked you MySQL connection charset?
– Eriks Klotins
Jan 2 at 14:40
I suggest to leave wp alone and try to troubleshoot the problem with the standalone script. Have you checked you MySQL connection charset?
– Eriks Klotins
Jan 2 at 14:40
That is what I tried under update 3 right? It says utf8 already.
– Flo
Jan 2 at 14:41
That is what I tried under update 3 right? It says utf8 already.
– Flo
Jan 2 at 14:41
I am not sure how exactly the wp-config handles charsets. That is why I suggested working with the standalone script where you have full control. Importantly, the script charset, the connection charset, and the DB charset have to be the same for things to work.
– Eriks Klotins
Jan 2 at 14:44
I am not sure how exactly the wp-config handles charsets. That is why I suggested working with the standalone script where you have full control. Importantly, the script charset, the connection charset, and the DB charset have to be the same for things to work.
– Eriks Klotins
Jan 2 at 14:44
add a comment |
1
Your host does not seem to be the problem ... leave it to localhost. Make sure DB_NAME, DB_USER, DB_PASSWORD is well defined. Maby a type in one of them?
– Patrick Simard
Dec 30 '18 at 16:41
You keep overwriting those, so only the last one takes effect.
– Funk Forty Niner
Dec 30 '18 at 16:47
1
Lol i am pretty sure he was just listing what he tryed
– Patrick Simard
Dec 30 '18 at 16:49
@PatrickSimard: I was indeed listing what I tried :-), I also rechecked name/user/password and literally copied them in workbench to test and it works there, so no typos. What else could it be? I'm running MySQL as a Windows service if that matters.
– Flo
Dec 31 '18 at 15:26
1
this help: stackoverflow.com/questions/43437490/… ?
– treyBake
Jan 2 at 14:43