MySQL Forums
Forum List  »  PHP

Re: Error 2054 Server sent charset unknown to the client.
Posted by: Peter Sjöstedt
Date: June 06, 2020 11:45PM

I have minimized my code to the following;
<?php

$host="localhost";
$port=3306;
$socket="";
$user="root";
$password="aq2LLhsu";
$dbname="scorecard";
$charset="utf8mb4";

/*
echo "host:" . $host . "<br>\n";
echo "user:" . $user . "<br>\n";
echo "password:" . $password . "<br>\n";
echo "dbname:" . $dbname . "<br>\n";
*/

$link = mysqli_connect($host, $user, $password, $dbname);

if (!$link) {
echo "Error: Unable to connect to MySQL." . "<br>\n";
echo "Debugging errno: " . mysqli_connect_errno() . "<br>\n";
echo "Debugging error: " . mysqli_connect_error() . "<br>\n";
exit;
}

echo mysqli_set_charset ($link, $charset) . "<br>\n";

echo "Success: A proper connection to MySQL was made! The my_db database is great." . "<br>\n";
echo "Host information: " . mysqli_get_host_info($link) . "<br>\n";

mysqli_close($link);

?>

It gives the following results;
Error: Unable to connect to MySQL.
Debugging errno: 2054
Debugging error: Server sent charset unknown to the client. Please, report to the developers

MySQL 8.0 Command Line Client gives the following results;
mysql: [Warning] C:\Program Files\MySQL\MySQL Server 8.0\bin\mysql.exe: ignoring option '--no-beep' due to invalid value ''.
Enter password: **********
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 15
Server version: 8.0.20 MySQL Community Server - GPL

Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

Options: ReplyQuote




Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.