MySQL 5.0 FAQ: MySQL Chinese, Japanese, and Korean Character Sets
mysql>
SHOW WARNINGS\G
*************************** 1. row ***************************
Level: Warning
Code: 1366
Message: Incorrect string value: '\xE6\xB1\x8CB' for column 'gb2312' at row 1
1 row in set (0.00 sec)
So it is a warning about the
mysql> SELECT ucs2,HEX(ucs2),gb2312,HEX(gb2312) FROM ch;
+-------+--------------+--------+-------------+
| ucs2
| HEX(ucs2)
+-------+--------------+--------+-------------+
| A汌B | 00416C4C0042 | A?B
+-------+--------------+--------+-------------+
1 row in set (0.00 sec)
Several things need explanation here:
1. The fact that it is a "warning" rather than an "error" is characteristic of MySQL. We like to try to do
what we can, to get the best fit, rather than give up.
汌
2. The
character is not in the
3. If you are using an old version of MySQL, you will probably see a different message.
4. With
sql_mode=TRADITIONAL
B.11.10: Why does my GUI front end or browser not display CJK characters correctly in my
application using Access, PHP, or another API?
Obtain a direct connection to the server using the
same query there. If
mysql
requires initialization. Use
'char%';. If you are using Access, then you are most likely connecting with
VARIABLES LIKE
Connector/ODBC. In this case, you should check
for instance, you use big5, you would enter
case). If you are using ASP, you might need to add
has worked in the past:
<%
Session.CodePage=0
Dim strConnection
Dim Conn
strConnection="driver={MySQL ODBC 3.51 Driver};server=server;uid=username;" \
& "pwd=password;database=database;stmt=SET NAMES 'big5';"
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open strConnection
%>
In much the same way, if you are using any character set other than
then you must specify the character set in the connection string. See
MySQL Using
Connector/Net", for more information.
If you are using PHP, try this:
<?php
$link = mysql_connect($host, $usr, $pwd);
mysql_select_db($db);
if( mysql_error() ) { print "Database ERROR: " . mysql_error(); }
mysql_query("SET NAMES 'utf8'", $link);
?>
In this case, we used
SET NAMES
character_set_connection
column only.
gb2312
| gb2312 | HEX(gb2312) |
| 413F42
character set. We described that problem earlier.
gb2312
[495], there would be an error message, rather than a warning.
responds correctly, then the trouble may be that your application interface
to tell you what character set or sets it uses with the statement
mysql
SET NAMES
to change
character_set_client
[442]
and
character_set_results
2897
|
client (Windows: mysql.exe), and try the
mysql
Section 20.1.4, "Configuring
'big5'. (Note that no
in the code. Here is an example that
SET NAMES
latin1
Section 20.2.5.1, "Connecting to
Connector/ODBC". If,
is required in this
;
with Connector/Net,
[441]
and
[443].
SHOW