Details
-
Bug
-
Status: Closed (View Workflow)
-
Blocker
-
Resolution: Fixed
-
11.3.1
-
None
-
Ubuntu 22.04 LTS
Kernel 5.15.0-91-generic
PHP 8.3.0
Description
Some charset change in MariaDB 11.3.1 appears to break PHP clients, raising the error 'Server sent charset (0) unknown to the client'.
I noticed /etc/mysql/mariadb.conf.d/50-server.cnf changed
collation-server = utf8mb4_general_ci (11.2.2)
to
character-set-collations = utf8mb4=uca1400_ai_ci (11.3.1)
If I change this back, connections from PHP work again.
This Plesk user seems to have encountered the same issue: https://talk.plesk.com/threads/500-plesk-exception-database-db-query-failed-sqlstate-hy000-2054-server-sent-charset-0-unknown-to-the-client.372563/
Steps to reproduce:
- Install PHP 8.3, including MySQLi extension.
- Install MariaDB 11.3.1, CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';.
- Test a PHP page, e.g.
<?php
error_reporting(E_ALL);
ini_set('display_errors', 'on');
$conn = new mysqli("localhost", "username", "password");
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
echo "Connected successfully";
?>
- Observe error:
Fatal error: Uncaught mysqli_sql_exception: Server sent charset (0) unknown to the client. Please, report to the developers in /var/www/html/index.php:4 Stack trace: #0 /var/www/html/index.php(4): mysqli->__construct() #1 {main} thrown in /var/www/html/index.php on line 4
Attachments
Issue Links
- is caused by
-
MDEV-32336 deb: 50-server.cnf:collation-server = utf8mb4_general_ci dated- replace with utf8mb4_uca1400_ai_ci
-
- Closed
-
- relates to
-
CONJS-281 cannot connect to 11.3+ server with character-set-collations = utf8mb4=uca1400_ai_ci
-
- Closed
-
-
MDEV-32966 "default collation" ids for the protocol
-
- Closed
-
-
MDEV-33182 Server assertion fails when trying to test the connection with DBeaver
-
- Closed
-
- links to
it's coming from https://github.com/php/php-src/blob/642e11140c3a8461ab9a78d6ce3d3a79b0151987/ext/mysqlnd/mysqlnd_commands.c#L619
and the reason is that the server sends 0 in the server default collation byte of the initial handshake packet for collations that are above 1..255 range.
But actually the connector is mainly interested in the character set, not the collation. We could try to "gracefully downgrade" the collation and if it's above 255, return another collation of the same character set but with a smaller id.