自宅サーバー構築メモ(その7) tritonn(MySQL)をインストール(その4)
mysqld
mysqldプログラムは[mysqld]、[server]セクションに記述したオプションを読み取ります。
[mysqld]セクションに記述できるオプションは、mysqldに--verbose --helpを指定して実行するか、mysqladminにvariablesを指定して実行することで知ることができます。
*出力されるオプションの量が多いので大分端折っています。
#mysqld --verbose --help
mysqld Ver 5.0.87-modified-log for unknown-linux-gnu on x86_64 (MySQL Community Server (GPL) (portions (c) Tritonn Project))
Copyright (C) 2000 MySQL AB, by Monty and others
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL license
Starts the MySQL database server
Usage: mysqld [OPTIONS]
Default options are read from the following files in the given order:
/etc/my.cnf ~/.my.cnf
The following groups are read: mysql_cluster mysqld server mysqld-5.0
The following options may be given as the first argument:
--print-defaults Print the program argument list and exit
--no-defaults Don't read default options from any options file
--defaults-file=# Only read default options from the given file #
--defaults-extra-file=# Read this file after the global files are read
~途中省略~
Variables (--variable-name=value)
and boolean options {FALSE|TRUE} Value (after reading options)
--------------------------------- -----------------------------
character-set-client-handshake TRUE
character-set-filesystem binary
character-set-server utf8
character-sets-dir /usr/share/mysql/charsets/
collation-server utf8_general_ci
datadir /var/lib/mysql/
default-character-set utf8
default-collation utf8_general_ci
default-time-zone (No default value)
innodb TRUE
innodb_checksums TRUE
innodb_data_home_dir /var/lib/mysql/
innodb_adaptive_hash_index TRUE
innodb_doublewrite TRUE
innodb_fast_shutdown 0
innodb_file_per_table TRUE
innodb_flush_log_at_trx_commit 1
innodb_flush_method (No default value)
innodb_locks_unsafe_for_binlog FALSE
innodb_log_arch_dir /var/lib/mysql/
innodb_log_group_home_dir /var/lib/mysql/
innodb_max_dirty_pages_pct 90
innodb_max_purge_lag 0
innodb_rollback_on_timeout FALSE
innodb_status_file FALSE
innodb_support_xa TRUE
innodb_table_locks TRUE
innodb_use_legacy_cardinality_algorithm TRUE
senna-2ind FALSE
senna-index-type (No default value)
senna-log (No default value)
senna-log-level (No default value)
innodb_additional_mem_pool_size 20971520
innodb_autoextend_increment 8
innodb_buffer_pool_awe_mem_mb 0
innodb_buffer_pool_size 536870912
innodb_commit_concurrency 0
innodb_concurrency_tickets 500
innodb_file_io_threads 4
innodb_force_recovery 0
innodb_lock_wait_timeout 50
innodb_log_buffer_size 8388608
innodb_log_file_size 134217728
innodb_log_files_in_group 3
innodb_mirrored_log_groups 1
innodb_open_files 300
innodb_sync_spin_loops 20
innodb_thread_concurrency 8
innodb_thread_sleep_delay 10000
To see what values a running MySQL server is using, type
'mysqladmin variables' instead of 'mysqld --verbose --help'.
*青字の個所はtritonn固有のオプションです。
参照:
4.2.2. コマンド オプション
文字コードの指定
クライアントとサーバーで文字コードをutf8に統一するための記述として
[client]
default-character-set=utf8
[mysqld]
default-character-set=utf8
というのを良く見かけますが、このdefault-character-setとは別にcharacter-set-serverがあります。
この2つは機能的にほぼ同じようで、default-character-setの代わりにcharacter-set-server=utf8としても同じように文字コードを指定することができます。
では、character-set-serverは何なのかということですが、マニュアルに以下のようにありました。
--default-character-set=charset_name (DEPRECATED)
デフォルトのキャラクタ セットを設定するときに、 charset_name を使用する。このオプションは --character-set-server をうけて、廃止予定である。
同じように照合順を指定するdefault-collationも廃止予定です。
--default-collation=collation_name
デフォルトの照合順序を設定するときに collation_name を使用する。このオプションは --collation-server をうけて、廃止予定である。
ということなので、今後は下記のように記述するほうが良いと思います。
[client]
default-character-set=utf8
[mysqld]
character-set-server=utf8
collation-server=utf8_general_ci
それから、character-set-serverはsetコマンドで動的に変更することができます。
(*↓ハイフンではなくアンダースコアです。)
mysql>set character_set_server=utf8;
Query OK, 0 rows affected (0.00 sec)
使用できる文字コード、照合順を調べる
--文字コード
show character set;
--照合順
show collation;
その5へ続く