To align both the character set (e.g., utf8mb4) AND the collation sequence with the schema (database) settings: connect_errno ) throw new Exception( $mysqli->connect_error, $mysqli->connect_errno ); if ( TRUE !== $mysqli->set_charset( ‘utf8mb4’ ) ) throw new Exception( $mysql->error, $mysqli->errno ); if ( TRUE !== $mysqli->query( ‘SET collation_connection = @@collation_database;’ ) ) throw new Exception( $mysql->error, $mysqli->errno ); ?> To confirm: character_set_name(), ‘
‘, PHP_EOL; foreach( $mysqli->query( “SHOW VARIABLES LIKE ‘%_connection’;” )->fetch_all() as $setting ) echo $setting[0], ‘: ‘, $setting[1], ‘
‘, PHP_EOL; ?> will output something like: character_set_name: utf8mb4 character_set_connection: utf8mb4 collation_connection: utf8mb4_unicode_520_ci