How to switch default MySql driver for PHP?

719 Views Asked by At

I am running a legacy system on the server with PHP 5.5.38 and am trying to connect with PDO to a MySQL 8.0 database, which results in the famous "Server sent charset unknown to the client. Please, report to the developers" error.

I've already tried sending PDO::MYSQL_ATTR_INIT_COMMAND "SET NAMES 'utf8'", but this didn't solve the problem.

The default MySql driver is mysqlnd. I noticed that the PDO Driver for MySQL has Client API version mysqlnd 5.0.11-dev - 20120503.

I was able to successfully connect on a different environment running PHP 5.5.38 where the PDO Driver for MySQL has Client API version 5.1.73 and where the default MySql driver is not mysqlnd.

Is it possible to install and switch to a different PHP MySql driver without recompiling PHP?

1

There are 1 best solutions below

1
lovecy On

Maby you should check your mysql character config, try to add or modify this in you mysql config file, and restar you mysql server.

[mysqld]
character-set-server = utf8

mysqlnd 5.0.11 can't identify MySQL 8's new Unicode types