Our system required data sync between each sub system, and it charged by be, last friday I think data sync maybe finished, but at six o'clock before I went to home, I found a problem, The sql from binlog have a problem that it can't display Chinese word right, so it changed the sql structure, sql maybe like this:
update user set id='145', name='乱码?, version='10';
Our database use innodb and out tables use UTF-8 character set, I search this problem by google and other search engine, but there are less info, it can't help me to solve this problem.
When go home, I write a test of problem, use mysql 5.0.18
drop table test;
create table test(
name text default null
)engine=INNODB DEFAULT CHARSET=utf8;
insert into test(name) values ("测试");
mysqlbinlog --hexdump E:\programing\Mysql\data\mysql-bin.000001>E:\test.sql
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES 15 */;
DELIMITER /*!*/;
# at 4
#8118 9:58:42 server id 1 end_log_pos 102 Start: binlog v 4, server v 5.1.17-beta-community-nt-debug-log created 8118 9:58:42 at startup
# Warning: this binlog was not closed properly. Most probably mysqld crashed writing it.
ROLLBACK/*!*/;
# at 102
#8118 9:59:31 server id 1 end_log_pos 183 Query thread_id=3 exec_time=0 error_code=0
SET TIMESTAMP=1226109571/*!*/;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1/*!*/;
SET @@session.sql_mode=0/*!*/;
/*!\C latin1 *//*!*/;
SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/;
create database web/*!*/;
# at 183
#8118 9:59:37 server id 1 end_log_pos 322 Query thread_id=3 exec_time=0 error_code=0
use web/*!*/;
SET TIMESTAMP=1226109577/*!*/;
create table test(
name text default null
)engine=INNODB DEFAULT CHARSET=utf8/*!*/;
# at 322
#8118 9:59:38 server id 1 end_log_pos 100 Query thread_id=3 exec_time=0 error_code=0
SET TIMESTAMP=1226109578/*!*/;
insert into test(name) values ("测试")/*!*/;
# at 422
#8118 9:59:38 server id 1 end_log_pos 449 Xid = 11
COMMIT/*!*/;
# at 449
#8118 10:5:20 server id 1 end_log_pos 526 Query thread_id=4 exec_time=0 error_code=0
SET TIMESTAMP=1226109920/*!*/;
drop table test/*!*/;
# at 526
#8118 10:5:20 server id 1 end_log_pos 665 Query thread_id=4 exec_time=0 error_code=0
SET TIMESTAMP=1226109920/*!*/;
create table test(
name text default null
)engine=INNODB DEFAULT CHARSET=utf8/*!*/;
# at 665
#8118 10:5:21 server id 1 end_log_pos 100 Query thread_id=4 exec_time=0 error_code=0
SET TIMESTAMP=1226109921/*!*/;
insert into test(name) values ("测试")/*!*/;
# at 765
#8118 10:5:21 server id 1 end_log_pos 792 Xid = 17
COMMIT/*!*/;
# at 792
#8118 10:6:16 server id 1 end_log_pos 93 Query thread_id=4 exec_time=0 error_code=0
SET TIMESTAMP=1226109976/*!*/;
update test set name="我很很晕"/*!*/;
# at 885
#8118 10:6:16 server id 1 end_log_pos 912 Xid = 18
COMMIT/*!*/;
DELIMITER ;
# End of log file
ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
All goes on, Oh, god, I think maybe this problem happened at hibernate insert data into database.
This make me headache!