Specify character settings at MySQL configuration time. To select a character set and collation
when you configure and build MySQL from source, use the
collation
shell>
./configure --with-charset=utf8 --with-collation=utf8_general_ci
The resulting server uses
and for client connections. It is unnecessary to use
collation-server
applications to configure their connection using
server.
Regardless of how you configure the MySQL character set for application use, you must also consider
the environment within which those applications execute. If you will send statements using UTF-8 text
taken from a file that you create in an editor, you should edit the file with the locale of your environment
set to UTF-8 so that the file encoding is correct and so that the operating system handles it correctly.
If you use the
UTF-8 or characters may not display properly. For a script that executes in a Web environment, the
script must handle character encoding properly for its interaction with the MySQL server, and it must
generate pages that correctly indicate the encoding so that browsers know how to display the content
of the pages. For example, you can include this
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
10.1.6. Character Set for Error Messages
This section describes how the server uses character sets for constructing error messages and
returning them to clients. For information about the language of error messages (rather than the
character set), see
In MySQL 5.0, the server constructs error messages and returns them to clients as follows:
• The message template has the character set associated with the error message language. For
example, English, Korean, and Russian messages use latin1, euckr, and koi8r, respectively.
• Parameters in the message template are replaced with values that apply to a specific error
occurrence. These parameters use their own character set. Identifiers such as table or column
names use UTF-8. Data values retain their character set. For example, in the following duplicate-key
message,
Duplicate entry 'xxx' for key1
The preceding method of error-message construction can result in messages that contain a mix of
character sets unless all items involved contain only ASCII characters. This issue is resolved in MySQL
5.5, in which error messages are constructed internally within the server using UTF-8 and returned to
the client in the character set specified by the
10.1.7. Collation Issues
The following sections discuss various aspects of character set collations.
10.1.7.1. Collation Names
MySQL collation names follow these rules:
• A name ending in
• A name ending in
• A name ending in
binary code values.
Character Set for Error Messages
[122]
options:
and
utf8
[403]
to specify those defaults at server startup. It is also unnecessary for
client from within a terminal window, the window must be configured to use
mysql
Section 10.2, "Setting the Error Message
has the character set of the table column associated with key 1:
'xxx'
indicates a case-insensitive collation.
_ci
indicates a case-sensitive collation.
_cs
indicates a binary collation. Character comparisons are based on character
_bin
as the default for databases and tables
utf8_general_ci
--character-set-server
SET NAMES
tag within your
<meta>
character_set_results
780
[122]
--with-charset
[403]
or equivalent after they connect to the
element:
<head>
Language".
[443]
system variable.
and
--with-
and
--
Need help?
Do you have a question about the 5.0 and is the answer not in the manual?
Questions and answers