嗯,用word打开两个文件有选择文本编码的提示:
在代码中执行select * from mytable 返回结果集,再自己写文件保存的文本用word打开,编码是GB2312;
但是select * from mytable into outfile '/tmp/dbinfo.txt';用word打开dbinfo.txt,编码是UTF-8.
这就解释了为什么前者显示正常,后者乱码了。
但是没想明白的是为什么有这两种编码的差异?
set names 'gbk'后,
character_set_client gbk
character_set_connection gbk
character_set_database latin1
character_set_filesystem binary
character_set_results gbk
character_set_server latin1
character_set_system utf8
但这时候 select * from mytable into outfile '/tmp/dbinfo.txt';得到的中文字符还是乱码~
为什么呢?
其实我更想知道的是:
之前我的设置全是latin1时,
1,在mysql客户端中直接执行 select * from mytable;得到的中文字符时正常的;
2,在代码中执行select * from mytable 返回结果集,再自己写文件保存,得到的中文字符也是正常的。
为什么这两种情况下得到的中文字符是正常的,而select * from mytable into outfile '/tmp/dbinfo.txt' dbinfo.txt中的中文字符就乱码?