PHP5.6 with MySQL 8 in Amazon RDS

81 Views Asked by At

I recently upgraded my database server from MySQL 5.7 to MySQL 8 because AWS warned me about the end of support for MySQL 5.7. After I upgraded I noticed one of the CakePHP (2.x) apps threw an error saying

PDOException' with message 'SQLSTATE[HY000] [2054] Server sent charset unknown to the client'
  1. I tried to view the character set in MySQL 8
SELECT DEFAULT_CHARACTER_SET_NAME, DEFAULT_COLLATION_NAME
FROM INFORMATION_SCHEMA.SCHEMATA
WHERE SCHEMA_NAME = 'your_database_name';
> utf8mb3

This is strange since the parameter group in AWS says it is utf8mb4 2. I tried to connect on client (CakePHP 2.x) by updating php.ini

default_charset = "utf8mb3"
pdo_mysql.default_charset = utf8mb3
  1. I tried to change it in app/Config/database.php
public $default = array(
    'datasource' => 'Database/Mysql',
    'persistent' => false,
    'host' => 'localhost',
    'login' => 'username',
    'password' => 'password',
    'database' => 'database_name',
    'prefix' => '',
    'encoding' => 'utf8mb3', // Set character set to utf8mb3
    'collation' => 'utf8mb3_general_ci', // Set collation to utf8mb3_general_ci
);

Still I am not able to get past this error. Please help me on this

0

There are 0 best solutions below