Legacy Knowledge Base
Published Jul. 2, 2025

Full support for Unicode in a Liferay PaaS database

Written By

Jose Jimenez

How To articles are not official guidelines or officially supported documentation. They are community-contributed content and may not always reflect the latest updates to Liferay DXP. We welcome your feedback to improve How To articles!

While we make every effort to ensure this Knowledge Base is accurate, it may not always reflect the most recent updates or official guidelines.We appreciate your understanding and encourage you to reach out with any feedback or concerns.

Legacy Article

You are viewing an article from our legacy "FastTrack" publication program, made available for informational purposes. Articles in this program were published without a requirement for independent editing or verification and are provided"as is" without guarantee.

Before using any information from this article, independently verify its suitability for your situation and project.
Note: please note that Liferay has renamed its Liferay Experience Could offerings to Liferay SaaS (formerly LXC) and Liferay PaaS (formerly LXC-SM).

Issue

  • Emoji symbols can not be stored in database, for example as part of a new web content. 
  • In the Liferay service's log you get this kind of errors: 
    [JDBCExceptionReporter:234] Incorrect string value: '\xF0\x9F\x8F\x80</...' for column 'content' at row 1

Environment

  • Liferay PaaS with the database in the utf8 charset.
    • This can be checked using the MySQL client:

      SELECT schema_name AS 'database', default_character_set_name AS 'charset', default_collation_name AS 'collation' FROM information_schema.SCHEMATA WHERE schema_name = 'lportal';
      +----------+---------+-----------------+
      | database | charset | collation |
      +----------+---------+-----------------+
      | lportal | utf8 | utf8_general_ci |
      +----------+---------+-----------------+
      1 row in set (0.001 sec)

Resolution

  • MySQL's utf8 charset only supports the storage of UTF-8 encoded symbols taking one to three bytes. For a full support of unicode you should use the utf8mb4 charset instead.

  • For a new project (with data loss)
    1. Modify your database/LCP.json and add the environment variable LCP_GCP_DATABASE_CHARSET": "utf8mb4"  to each environment in where your database service is going to be deployed:
      ...
        "environments": {
          "infra": {
            "deploy": false
          },
          "prd": {
            "env": {
              "LCP_GCP_DATABASE_CHARSET": "utf8mb4"
            }
          },
          "uat": {
            "env": {
              "LCP_GCP_DATABASE_CHARSET": "utf8mb4"
            }
          },
          "dev": {
            "env": {
              "LCP_GCP_DATABASE_CHARSET": "utf8mb4"
            }
          }
        }
      ...
    2. Create a new build.
    3. Create a complete backup if you are working with the prd environment, just in case it is needed.
    4. Delete the existing database service from the Liferay PaaS console. This operation is going to remove also your database.
    5. Deploy the new build.

  • For existing projects (without data loss)
    1. Download a backup.
    2. Import the dump in an empty MySQL database.
    3. Convert the database from utf8 to utf8mb4 . If you do not know a specific tool you can find a manual process in this article.
    4. Get a dump of the converted database and upload a complete backup by following the Migrating from an on premises DXP installation guide.
    5. Create a clean utf8mb4 database in Liferay Cloud by following the steps 1-5 of the For a new project process.
    6. Restore the complete backup uploaded in the step 4.

Note: Restoring an old utf8 backup in a utf8mb4 database would lose the utf8mb4 configuration.

Additional Information

 

Did this article resolve your issue ?

Legacy Knowledge Base