2012年1月30日月曜日

Redmine 1.3.0! #03 まずは MySQL

じっけんかいし

VMWare に Debian 6.0 Squeeze をインストール。

お好みで sudo をインストールして visudo で立ち上がる nano をアンインストールして vim-tiny をアンインストールして vim をインストールとか。

MySQL

まずは MySQL から。$ apt-cache search mysql するとスクロールしてすごいことになるからこう。

$ apt-cache search ^mysql --names-only
mysql-gui-tools-common - Architecture independent files for MySQL GUI Tools
mysql-mmm-agent - Multi-Master Replication Manager for MySQL - agent daemon
mysql-mmm-common - Multi-Master Replication Manager for MySQL - common files
mysql-mmm-monitor - Multi-Master Replication Manager for MySQL - monitoring daemon
mysql-mmm-tools - Multi-Master Replication Manager for MySQL - tools
mysql-proxy - high availability, load balancing and query modification for mysql
mysqltcl - Interface to the MySQL database for the Tcl language
mysqltuner - high-performance MySQL tuning script
mysql-admin - 直感的な MySQL 管理のための GUI ツール
mysql-client - MySQL データベースクライアント (最新版に依存するメタパッケージ)
mysql-client-5.1 - MySQL データベースクライアントバイナリ
mysql-common - MySQL データベース共通ファイル (/etc/mysql/my.cnf など)
mysql-navigator - MySQL データベースサーバ用 GUI クライアントプログラム
mysql-query-browser - MySQL データベース問い合わせ用公式 GUI ツール
mysql-server - MySQL データベースサーバ (最新版に依存するメタパッケージ)
mysql-server-5.1 - MySQL データベースサーババイナリおよびシステムデータベースの設定
mysql-server-core-5.1 - MySQL データベースサーババイナリ

さーばーが必要なの,いつも忘れるんだよね。最初に一回しかやらないから。

で,インストール。

$ sudo apt-get install mysql-server
パッケージリストを読み込んでいます... 完了
依存関係ツリーを作成しています
状態情報を読み取っています... 完了
以下の特別パッケージがインストールされます:
  libdbd-mysql-perl libdbi-perl libhtml-template-perl libmysqlclient16
  libnet-daemon-perl libplrpc-perl mysql-client-5.1 mysql-common
  mysql-server-5.1 mysql-server-core-5.1
提案パッケージ:
  libipc-sharedcache-perl libterm-readkey-perl tinyca
以下のパッケージが新たにインストールされます:
  libdbd-mysql-perl libdbi-perl libhtml-template-perl libmysqlclient16
  libnet-daemon-perl libplrpc-perl mysql-client-5.1 mysql-common mysql-server
  mysql-server-5.1 mysql-server-core-5.1
アップグレード: 0 個、新規インストール: 11 個、削除: 0 個、保留: 0 個。
24.1 MB のアーカイブを取得する必要があります。
この操作後に追加で 61.1 MB のディスク容量が消費されます。
続行しますか [Y/n]?
パッケージの設定

 ┌------------------┤ mysql-server-5.1 を設定しています ├------------------┐
 │ 強制ではありませんが、MySQL を管理する "root" ユーザのパスワードを設定す  │
 │ ることを強くお勧めします。                                                │
 │                                                                           │
 │ この値を空のままにしておいた場合は、パスワードは変更されません。          │
 │                                                                           │
 │ MySQL の "root" ユーザに対する新しいパスワード:                           │
 │                                                                           │
 │ _________________________________________________________________________ │
 │                                                                           │
 │                                  <了解>                                   │
 │                                                                           │
 └---------------------------------------------------------------------------┘

パッケージの設定


              ┌-----┤ mysql-server-5.1 を設定しています ├------┐
              │                                                  │
              │                                                  │
              │ MySQL の "root" ユーザに対する新しいパスワード:  │
              │                                                  │
              │ ________________________________________________ │
              │                                                  │
              │                      <了解>                      │
              │                                                  │
              └--------------------------------------------------┘

文字コードの設定とか

/etc/mysql/my.cnf を書き換える,では無くて。というのも,my.cnf の最後には,

#
# * IMPORTANT: Additional settings that can override those from this file!
#   The files must end with '.cnf', otherwise they'll be ignored.
#
!includedir /etc/mysql/conf.d/

とあるので,/etc/mysql/conf.d/ に設定を放り込んでおけばいいの。たとえばこんなの,utf8.cnf とでも名前をつけて。

[client]
        default-character-set           = utf8

[mysqld]
        character_set_server            = utf8

[mysqldump]
        default-character-set           = utf8

[mysql]
        default-character-set           = utf8

確認するよ。まずは何もしていない状態で。

$ mysql --user root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 40
Server version: 5.1.49-3 (Debian)

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show variables like 'char%';
+--------------------------+----------------------------+
| Variable_name            | Value                      |
+--------------------------+----------------------------+
| character_set_client     | utf8                       |
| character_set_connection | utf8                       |
| character_set_database   | latin1                     |
| character_set_filesystem | binary                     |
| character_set_results    | utf8                       |
| character_set_server     | latin1                     |
| character_set_system     | utf8                       |
| character_sets_dir       | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.00 sec)

mysql> exit
Bye

設定ファイルを放り込んだら,

$ sudo /etc/init.d/mysql restart

で MySQL を再起動して。

もう一度チェック。

$ mysql --user root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 35
Server version: 5.1.49-3 (Debian)

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

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       | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.00 sec)

mysql> exit
Bye

0 件のコメント: