Monday, August 10, 2009

japanese in mysql databases

grr.. what is it today... to get nihongo working in mysql

1) verify that the issue is the db encoding, it needs to read line this example

mysql -u[usename] -p[password] [database]
show variables like "%character%";show variables like "%collation%";
+--------------------------+----------------------------+
| Variable_name            | Value                      |
+--------------------------+----------------------------+
| character_set_client     | utf8                       |
| character_set_connection | utf8                       |
| character_set_database   | utf8                       |
| character_set_filesystem | binary                     |
| character_set_results    | utf8                       |
| character_set_server     | utf8                       |
| character_set_system     | utf8                       |
| character_sets_dir       | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.00 sec)

+----------------------+-----------------+
| Variable_name        | Value           |
+----------------------+-----------------+
| collation_connection | utf8_general_ci |
| collation_database   | utf8_general_ci |
| collation_server     | utf8_general_ci |
+----------------------+-----------------+
3 rows in set (0.00 sec)

2) the fix;
sudo emacs /etc/mysql/my.cnf

then add/edit the lines (in the correct sections)
[mysqld]
default-character-set=utf8

[mysql]
default-character-set=utf8

then reboot the server
/etc/init.d/mysql restart

then recreate the db from scratch or export all the data/recreate and import it..

No comments:

Post a Comment