Consciousness

MySQL to pure utf-8 character set configuration

Posted in mySQL, python by Personalife on the December 25th, 2008

I’m programming a new version of my Japanese translator in the python Django framework as practice. Aside from some hard lessons, such as you cannot install a Python 2.5 x64 binary in Windows and expect the mod_python installer to work, the following was my next problem:

Had some trouble importing a file with Japanese in UTF-8 encoding into mySQL. The import would go fine, then would completely come out garbage on output. I eventually figured out what to do. Edit the my.cnf for the server, and use the following parameters:


[mysqld]
default-character-set=utf8
default-collation=utf8_general_ci
character-set-server=utf8
character-set-database=utf8
collation-server=utf8_general_ci
init-connect='SET NAMES utf8'

[mysql]
default-character-set=utf8

Now, if I did the following in mySQL:


mysql> SHOW VARIABLES LIKE 'char%';
+--------------------------+--------------------------------+
| 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       | C:\xampp\mysql\share\charsets\ |
+--------------------------+--------------------------------+
8 rows in set (0.00 sec)

mysql> SHOW VARIABLES LIKE 'collation%';
+----------------------+-----------------+
| 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)

If everything is utf8, then you are golden!

An incomplete thought

Posted in Thoughts by Personalife on the December 3rd, 2008

What is the origin of randomization?

What decides that randomization? On a macro level, a micro level, an atomic level, a quirk level…

Powered by WordPress .::. Designed by SiteGround Web Hosting