Databases 7 min read

Root Cause Analysis of Inconsistent MySQL Client Character Set on RedHat 7

The article investigates why two MySQL 5.7.32 installations on RedHat 7 show different client character sets—utf8 in the first batch and latin1 in the second—by reviewing MySQL charset settings, OS locale configuration, and providing corrective commands.

Aikesheng Open Source Community
Aikesheng Open Source Community
Aikesheng Open Source Community
Root Cause Analysis of Inconsistent MySQL Client Character Set on RedHat 7

During a routine inspection of newly deployed MySQL 5.7.32 instances on a RedHat 7 server, a client observed that the first batch used the utf8 character set while the second batch defaulted to latin1 . The article explains the investigation process and the root cause.

MySQL charset basics : MySQL distinguishes between server‑level and client‑level character sets. The server charset (controlled by character_set_server ) determines how data is stored, while the client charset (controlled by character_set_client , character_set_connection , and character_set_results ) governs how the client communicates with the server. All three client parameters should be consistent, typically set to utf8 (or utf8mb4 in MySQL 8.0).

Investigation steps :

Verified that the earlier installation indeed used utf8 for the client.

Examined all my.cnf files on the server; both old and new installations only defined character_set_server=utf8mb4 .

Checked the OS locale settings and discovered that the problematic machines were set to en_US while the original ones used en_US.UTF-8 .

Reproduced the issue by changing the server locale to en_US , which caused the MySQL client charset to switch to latin1 .

The MySQL documentation states that client tools have a default charset (latin1 for MySQL 5.7) and that they inherit the OS locale if it maps to a supported MySQL charset; otherwise they fall back to the default. Since en_US maps to latin1 , the client charset changed accordingly.

Fix :

-- Immediate effect (temporary)
export LANG="en_US.UTF-8"

-- Permanent effect
vim /etc/locale.conf
LANG="en_US.UTF-8"
source /etc/locale.conf

After restoring the OS locale to en_US.UTF-8 , the MySQL client charset returned to utf8 .

Conclusion :

The inconsistency was caused by the VM image’s OS locale being set to en_US instead of en_US.UTF-8 .

Server‑level charset is configured via character_set_server .

Client‑level charset depends on three parameters that should match and is also influenced by the server’s OS locale.

LinuxMySQLtroubleshootingcharacter setDatabase ConfigurationRedHat
Aikesheng Open Source Community
Written by

Aikesheng Open Source Community

The Aikesheng Open Source Community provides stable, enterprise‑grade MySQL open‑source tools and services, releases a premium open‑source component each year (1024), and continuously operates and maintains them.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.