MySQL Command Line Formatting with UTF8: Preserving Table Layout
Problem:
MySQL command line output for tables containing non-Latin characters becomes distorted when switching to UTF-8 encoding. This can hinder readability.
Short Answer:
Launch the MySQL client with the --default-character-set=utf8 option. Alternatively, set this option in the /etc/mysql/my.cnf file.
Detailed Explanation:
The --default-character-set option forces the character set variables (character_set_client, character_set_connection, and character_set_results) to UTF-8. This ensures that data is formatted properly even when displaying non-Latin characters.
However, if the problem persists, consider the following:
Consideration:
Note that MySQL's UTF-8 implementation (utf8) may not fully conform to the UTF-8 standard. If a true and full UTF-8 implementation is required, use the utf8mb4 charset instead.
The above is the detailed content of How Can I Display MySQL Tables with UTF-8 Characters Correctly?. For more information, please follow other related articles on the PHP Chinese website!