Chat (Lingr.com)
Informaiton
Daily
Column
- MySQL日本語の旅(5/1)
- アクセス向上秘伝(5/9)
- 一風変ったHaskellλ門(6/13)
- SICP Answer Book (5/31) 問題3.26追加
Zope Solution
Extra
アーカイブ
OSS案内所
Site Info
関連リンク
再び、バイナリ版に戻る
さて、MySQL AB では、できるだけバイナリ版を使うようにということだったので、 ここから後は、再びバイナリ版での動作を書くことにする。
バイナリ版でも日本語は使えるのだが、デフォルトが英語(latin1)になっているので、 必要に応じてなんらかの方法でオプション指定が必要になる。
mysqlクライアントのデフォルトのキャラクタセット
復習になるが、標準のバイナリ版のサーバを普通に起動し、
# /usr/local/mysql/bin/mysqld_safe --user=mysql &
mysqlクライアントコマンドもオプションなしで起動した場合に、 キャラクタセット関連のシステム変数がどうなっているか、もう一度見てみよう。
$ mysql Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 to server version: 4.1.10-standard-log Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> SHOW VARIABLES LIKE 'character\_set\_%'; +--------------------------+--------+ | Variable_name | Value | +--------------------------+--------+ | character_set_client | latin1 | | character_set_connection | latin1 | | character_set_database | latin1 | | character_set_results | latin1 | | character_set_server | latin1 | | character_set_system | utf8 | +--------------------------+--------+ 6 rows in set (0.05 sec) mysql>
mysqlコマンドでデフォルトキャラクタセットを指定して起動
mysqlコマンドのオプション指定をどうやるかは、 他のコマンドでもだいたいそうなんだが、--helpオプションを 付加してヘルプを見ればよい。
$ mysql --help
mysql Ver 14.7 Distrib 4.1.10, for pc-linux-gnu (i686)
Copyright (C) 2002 MySQL AB
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL license
Usage: mysql [OPTIONS] [database]
-?, --help Display this help and exit.
-I, --help Synonym for -?
--auto-rehash Enable automatic rehashing. One doesn't need to use
'rehash' to get table and field completion, but startup
and reconnecting may take a longer time. Disable with
--disable-auto-rehash.
-A, --no-auto-rehash
No automatic rehashing. One has to use 'rehash' to get
table and field completion. This gives a quicker start of
mysql and disables rehashing on reconnect. WARNING:
options deprecated; use --disable-auto-rehash instead.
-B, --batch Don't use history file. Disable interactive behavior.
(Enables --silent)
--character-sets-dir=name
Directory where character sets are.
--default-character-set=name
Set the default character set.
以下省略
これで、起動時にデフォルトのキャラクタセットを指定するには、
mysql --default-character-set=キャラクタセット
で良いことが分った。
では、さっそく実行してみよう。
$ mysql --default-character-set=ujis Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 to server version: 4.1.10-standard-log Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> SHOW VARIABLES LIKE 'character\_set\_%'; +--------------------------+--------+ | Variable_name | Value | +--------------------------+--------+ | character_set_client | ujis | | character_set_connection | ujis | | character_set_database | latin1 | | character_set_results | ujis | | character_set_server | latin1 | | character_set_system | utf8 | +--------------------------+--------+ 6 rows in set (0.00 sec) mysql>
すると、
- character_set_client
- character_set_connection
- character_set_results
の3つだけが、latin1 から ujis に変った。 どうも、この3つのシステム変数は、 mysqlのクライアントと関連するのではないだろうか。
戻る:5.0の新機能
フィードバック:
yuka: (Fri Jun 3 17:15:37 2005
)