shin
shin

Reputation: 32721

I am not able to enter Japanese character to MySQL

I tried to enter カテゴリ to MySQL, but I get the following

1 row(s) affected.
Warning: #1366 Incorrect string value: '\xE3\x82\xAB\xE3\x83\x86...' 
for column 'bloc_name' at row 1

I changed Collation to ujis_japanese_ci, but the result is the same. Can anyone suggest how to solve this? Thanks in advance.

Additional note

I created db like this,

CREATE TABLE dtb_bloc (
device_type_id int NOT NULL,
bloc_id int  NOT NULL,
bloc_name text,
tpl_path text,
filename varchar(50) NOT NULL,
create_date timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
update_date timestamp NOT NULL,
php_path text,
deletable_flg smallint NOT NULL DEFAULT 1,
PRIMARY KEY (device_type_id, bloc_id),
UNIQUE (device_type_id, filename)
) ENGINE=InnoDB;

+++++++++++++++

Additional note:

I am using MAMP, and the details are followings.

PHP Built On Darwin sokada-macbook.local 10.8.0 Darwin Kernel Version 10.8.0: Tue Jun 7 16:32:41 PDT 2011; root:xnu-1504.15.3~1/RELEASE_X86_64 x86_64

Database Version 5.5.9

Database Collation utf8_general_ci

PHP Version 5.3.6

Web Server Apache/2.2.17 (Unix) mod_ssl/2.2.17 OpenSSL/0.9.8r DAV/2 PHP/5.3.6

WebServer to PHP Interface apache2handler

Upvotes: 0

Views: 890

Answers (1)

Amadan
Amadan

Reputation: 198426

Collation only affects sorting, not which characters are allowed in and how they are stored, which is controlled by character set. Read this chapter for more understanding. You will most likely want 'ujis' or 'sjis' or 'utf8':

CREATE DATABASE db_name CHARACTER SET ujis COLLATE ujis_japanese_ci;

You may also want to invoke this as your first command from the client;

SET NAMES ujis COLLATE ujis_japanese_ci

Upvotes: 1

Related Questions