Skip to content

Changing the table collation in MySQL optimizes character sorting and comparison, suiting specific linguistic needs or correcting application behaviors. This alteration improves your database’s efficiency and accuracy in handling multilingual data. Here’s how to change your table’s collation effectively and ensure your application communicates as intended.

How to show the current collation?

Identify your table’s current character set and collation by executing this SQL query:

SHOW TABLE STATUS LIKE 'your_table_name';

This command reveals various properties, including the table’s current Collation. Replace 'your_table_name' with the actual name of your table.

Change table collation

Change your table’s default collation and character set using the ALTER TABLE statement:

ALTER TABLE your_table_name CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

In this command, substitute your_table_name with your table’s name, and replace utf8mb4 and utf8mb4_unicode_ci with the desired character set and collation. This alteration impacts all character columns within the table.

Change column collation

For specific column updates, modify each one with its new collation and character set:

ALTER TABLE your_table_name CHANGE column_name column_name VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

Here, you must replace your_table_name and column_name with the respective table and column names. Ensure the data type and length, such as VARCHAR(255), match the column’s original specifications.

Verify changes

Confirm the applied changes by listing all columns in your table along with their character set and collation:

SHOW FULL COLUMNS FROM your_table_name;

This command helps you check that each column now reflects the new collation and character set settings.

It’s essential to back up your data before adjusting collation to prevent data loss or corruption. Additionally, consider how these changes may affect data sorting, comparison, and overall application functionality to maintain seamless operation.

Written by

Robert Cooper avatar

Robert Cooper

Senior Engineer at Basedash

Robert Cooper is a senior engineer at Basedash who builds full-stack product systems across SQL data infrastructure, APIs, and frontend architecture. His work focuses on application performance, developer velocity, and reliable self-hosted workflows that make data operations easier for teams at scale.

View full author profile →

Looking for an AI-native BI tool?

Basedash lets you build charts, dashboards, and reports in seconds using all your data.