Encoding Problem Due to Unsupported Database Configuration

Still need help?

The Atlassian Community is here for you.

Ask the community


Symptoms

  1. Foreign characters are rendered as "????????" once the page is saved.


  2. Encoding test fails at database round-trip and it displays error "The file name has been mangled".

Diagnosis

  1. Perform encoding test via the following URL.

  2. Execute the following SQL queries to check the database character set and collation system variables that apply to your connection.

    • MySQL

    1. Return the values of the character set variables.

    SHOW VARIABLES LIKE 'character_set%';

    Sample

    +--------------------------+--------------------------------------------------------+
    | Variable_name            | Value                                                  |
    +--------------------------+--------------------------------------------------------+
    | character_set_client     | utf8                                                   |
    | character_set_connection | utf8                                                   |
    | character_set_database   | utf8                                                   |
    | character_set_filesystem | binary                                                 |
    | character_set_results    | utf8                                                   |
    | character_set_server     | utf8                                                   |
    | character_set_system     | utf8                                                   |
    | character_sets_dir       | /usr/local/mysql-5.5.x/share/charsets/                 |
    +--------------------------+--------------------------------------------------------+


    2. Return the values of the collation system variables.

    SHOW VARIABLES LIKE 'collation%';

    Sample

    +----------------------+-----------------+
    | Variable_name        | Value           |
    +----------------------+-----------------+
    | collation_connection | utf8_bin        |
    | collation_database   | utf8_bin        |
    | collation_server     | utf8_bin        |
    +----------------------+-----------------+

    3. Ensure that the JDBC Connection URL includes useUnicode=true and characterEncoding=utf8 flags.

Cause

The characters are tampered during the conversion between Confluence and database. The characters are changed to "?????" after the page is saved (database round-trip).

Resolution

  1. Ensure that the database is setup as described in Database Configuration documentations.
  2. If your collation_connection is neither utf8_bin nor utf8_general_ci, please add the following parameters to your MySQL database my.cnf (Unix) or my.ini (Windows) file under mysqld section.

    [mysqld]
    ...
    init_connect='SET collation_connection = utf8_bin; SET NAMES utf8;'
    character-set-server=utf8
    collation-server=utf8_bin
    default-storage-engine=INNODB
    ...

    (warning) You might need to add the following parameter as well if the above parameters do not take any effect. This parameter ignores the client handshake with the server and enforces UTF-8 on any database communications.

    skip-character-set-client-handshake
  3. Restart MySQL database.

  4. Re-execute the SQL queries mentioned in the Diagnosis Section to ensure the recent added parameter takes effects.

Last modified on Mar 10, 2023

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.