Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The method of dealing with garbled codes in MySQL binlog logs

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains the "MySQL binlog log garbled handling methods", the article explained the content is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in-depth, together to study and learn "MySQL binlog log garbled handling methods"!

OS:Red Hat Enterprise Linux Server release 6.5 (Santiago)

DB:5.6.30-log

Use mysqlbinlog to open the log and find that the contents of the log are garbled

The first thought is to check the character set of the MySQL database.

Found that the character set is consistent, looking at the operating system environment variables of the character set, found that the character set is always the same.

[root@mysql1 log] # echo $LANG

En_US.UTF-8

Then I looked up the information on the Internet and found that someone said

When the mysql server version is 5.6, be sure to use mysqlbinlog with version > = 3.4, otherwise there will be garbled problems.

Checked my mysqlbinlog version:

[root@mysql1 log] # mysqlbinlog-- version

Mysqlbinlog Ver 3.3 for redhat-linux-gnu at x86_64

It is found that the version is indeed lower than 3.4.

Then how to upgrade this separately? Can't the version that comes with MySQL 5.6.30 be used by itself?

Use the absolute path to query the version again:

[root@mysql1 log] # / mysql/bin/mysqlbinlog-- version

/ mysql/bin/mysqlbinlog Ver 3.4 for Linux at x86_64

You're kidding me! The absolute path is right.

Use the absolute path to view the log, the garbled code disappears.

Solve the relative path problem.

Check the setting of the environment variable .bash _ profile.

[root@mysql1 ~] # vi .bash _ profile

# .bash _ profile

# Get the aliases and functions

If [- f ~ / .bashrc]; then

. ~ / .bashrc

Fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin:/mysql/bin

Export PATH

When adding environment variables, / mysql/bin is added at the end, and the system reads the order of variables from front to back.

Check the / usr/bin directory, sure enough, there is a mysqlbinlog program, the query version is 3.3

[root@mysql1 bin] # / usr/bin/mysqlbinlog-- version

/ usr/bin/mysqlbinlog Ver 3.3 for redhat-linux-gnu at x86_64

Now that we know the cause of the problem, there are two ways to deal with it:

1. Modify .bash _ profile, put the / mysql/bin setting first, and reload the variable.

[root@mysql1 ~] # vi .bash _ profile

# .bash _ profile

# Get the aliases and functions

. ~ / .bashrc

Fi

# User specific environment and startup programs

PATH=/mysql/bin:$PATH:$HOME/bin

Export PATH

2. Delete the mysqlbinlog program in the / usr/bin directory and rename it. Then reload the variable.

[root@mysql1 bin] # mv mysqlbinlog mysqlbinlog.bak

Thank you for your reading, the above is the "MySQL binlog log garbled handling methods" of the content, after the study of this article, I believe that you have a deeper understanding of the MySQL binlog log garbled handling methods, the specific use of the need for you to practice and verify. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report