2

I am trying to enable emojis following Multi-byte UTF-8 support in Drupal 7.

I have added the following to the settings.php file.

  'charset' => 'utf8mb4',
  'collation' => 'utf8mb4_general_ci',

I've converted MySQL tables into utf8mb4 format and set the collate to utf8mb4_general_ci.

On the Drupal 8 site emojis work, while on the Drupal 7 I get the following error.

4 byte UTF-8 for mysql is activated, but not supported on your system. Please turn this off in settings.php, or ensure that all database-related requirements are met.

What am I missing?

Update

When I try to save a node with an emoji I receive the following error.

StatusText: Service unavailable (with message)
ResponseText: PDOException: SQLSTATE[HY000]: General error: 1366 Incorrect string value: '\xF0\x9F\x98\x8A'
  • What's your D7's core version? – No Sssweat Feb 18 at 18:55
  • @NoSssweat Thanks for replying, 7.69. – Tasha Jordan Feb 18 at 20:57
1

First I SUGGEST to take a look at https://www.drupal.org/project/utf8mb4_convert module

try to adding 'charset' => 'utf8mb4', 'collation' => 'utf8mb4_general_ci', configs to your settings.php file.

after adding it should be something like :

$databases['default']['default'] = array(
  'driver' => 'mysql',
  'database' => 'databasename',
  'username' => 'username',
  'password' => 'password',
  'host' => 'localhost',
  'charset' => 'utf8mb4',
  'collation' => 'utf8mb4_general_ci',
);

if it does not work for you, probably you need to change MySQL configs. use the following config in your MySQL configuration ( usually my.cnf or my.ini)

# Use UTF8MB4 as the character set
collation-server = utf8mb4_unicode_ci
init-connect='SET NAMES utf8mb4'
character-set-server = utf8mb4

another suggestion:

ALTER DATABASE dbname CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci;
SELECT CONCAT('ALTER TABLE `', TABLE_NAME,'` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;') AS mySQL
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA= "dbname"
AND TABLE_TYPE="BASE TABLE"

FINAL STEP to make the warning go away and get a clean Status Report:

USE YOURDATABASENAME;INSERT INTO variable SET name='drupal_all_databases_are_utf8mb4', value='b:1;';

my.ini or my.cnf add:

[mysqld]
innodb_large_prefix=true
innodb_file_format=barracuda
innodb_file_per_table=true

settings.php

  'charset' => 'utf8mb4',
  'collation' => 'utf8mb4_general_ci',
  • thanks for your answer. I havent used the module as I do not have Drush, but have done all the rest. I get the the same error on my Status Report even though I have ran the query 'INSERT INTO variable SET name='drupal_all_databases_are_utf8mb4', value='b:1;';' Which shows in my database. – Tasha Jordan Feb 18 at 21:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.