azureazure-web-app-serviceazure-mysql-database

Azure mysql connection redirection changes encoding


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?


Solution

  • 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