Home >Database >Mysql Tutorial >How to Fix Garbled Chinese and Japanese Characters by Changing Database Collation?
Database Character Set and Collation Modification Guide: Restoring Character Details
This guide solves the problem that incorrect database collation settings cause Chinese and Japanese characters to display garbled characters. The goal is to modify the collation and restore character detail.
Modify database sorting rules:
<code class="language-sql">ALTER DATABASE <database_name> CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci;</code>
Modify table sorting rules:
<code class="language-sql">ALTER TABLE <table_name> CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci;</code>
Modify column sorting rules:
<code class="language-sql">ALTER TABLE <table_name> MODIFY <column_name> VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci;</code>
utf8mb4_0900_ai_ci Meaning of each part:
Additional information:
The above is the detailed content of How to Fix Garbled Chinese and Japanese Characters by Changing Database Collation?. For more information, please follow other related articles on the PHP Chinese website!