Why is mysql 4 not respecting --character_set_results and --default-character-set command arguments?
I have a table 'ABC' (charset = utf8) and these are my character set variable values
[mysql version 4.1.23 - Server] and Client version - 3.23.57mysql> show variables like 'character%'; +--------------------------+------------------------------------+ | Variable_name | Value | +--------------------------+------------------------------------+ | character_set_client | latin1 | | character_set_connection | latin1 | | character_set_database | latin1 | | character_set_results | latin1 | | character_set_server | latin1 | | character_set_system | utf8 | | character_sets_dir | /home/y/share/mysql/charsets/ | +--------------------------+------------------------------------+ 7 rows in set (0.00 sec)
Now if I run a query in mysql client
mysql>s开发者_如何学运维elect * into outfile '/tmp/a' from ABC; Query OK, 26 rows affected (0.00 sec)
and check the filetype of /tmp/a
[satyavrk-~]$: file /tmp/a /tmp/a:UTF-8 Unicode text
Q1)Since my character_set_results is latin1 , how is the filetype of /tmp/a is UTF-8 instead of latin1 or ISO-8859 English text?
Alternatively if I run
[satyavrk-~]$: mysqldump -uroot --databases my --tables ABC --default-character-set=utf8 > 63794
and do
[satyavrk-~]$: file 63794 63794: ISO-8859 English text, with very long lines
Q2)Since I specified --default-character-set as UTF-8 the resultset should be utf8. But it is not! Why?
In both cases file type is different from expected
Can any one explain the point I am missing
SET NAMES
is convenient and probably just what you need.
I guess the problem is with mysql client. If I try doing the same with mysql client of version 4 . the second problem is solved!
In the documentation available at dev.mysql.com/doc/refman/5.0/en/select.html says "SELECT ... INTO OUTFILE is the complement of LOAD DATA INFILE. Column values are dumped using the binary character set. In effect, there is no character set conversion. If a table contains columns in several character sets, the output data file will as well and you may not be able to reload the file correctly." which means it doesn't read character_set_results.
精彩评论