0

I use a php app that connects to mysql in Azure. I use utf8mb4 as encoding and utf8mb4_unicode_ci as collation.

Everything works as usual when I connect to Mysql without connection forwarding. When I enable connection forwarding in the php.ini as described here I get errors about malformed UTF-8 characters when processing the results of database queries. Could it be possible that connection forwarding changes the encoding? If yes, can I disable it somehow?

stena
  • 667
  • 5
  • 19

1 Answers1

0

It seems that's a Bug when using the lib with PDO. The charset in the connection string is simply ignored.

It can be worked around by using SET NAMES utf8mb4 COLLATE utf8mb4_unicode_ci as PDO::MYSQL_ATTR_INIT_COMMAND

stena
  • 667
  • 5
  • 19
  • No only for PDO, mysqli will hit the issue as well. You can also mitigate it by init_connect='SET NAMES utf8mb4' – x_xiao2_bnu May 06 '21 at 04:18