インストール

  1. RPMの取得
    http://dev.mysql.com/downloads/mysql/5.0.html
    より、
    ・SLES9 (x86) - Server
    ・SLES9 (x86) - Client
    をダウンロードします。
  2. インストール
    > sudo rpm -ivh MySQL-server-standard-5.0.18-0.sles9.i586.rpm
    Password:
    警告: MySQL-server-standard-5.0.18-0.sles9.i586.rpm: V3 DSA signature: NOKEY, key ID 5072e1f5
    Preparing...                ########################################### [100%]
       1:MySQL-server-standard  ########################################### [100%]
    PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
    To do so, start the server, then issue the following commands:
    /usr/bin/mysqladmin -u root password 'new-password'
    /usr/bin/mysqladmin -u root -h grape password 'new-password'
    See the manual for more instructions.
    
    Please report any problems with the /usr/bin/mysqlbug script!
    
    The latest information about MySQL is available on the web at
    http://www.mysql.com
    Support MySQL by buying support/licenses at https://order.mysql.com
    Starting MySQL                                                        done
     
    > sudo rpm -ivh MySQL-client-standard-5.0.18-0.sles9.i586.rpm
    警告: MySQL-client-standard-5.0.18-0.sles9.i586.rpm: V3 DSA signature: NOKEY, key ID 5072e1f5
    Preparing...                ########################################### [100%]
       1:MySQL-client-standard  ########################################### [100%]
    >
  3. メッセージファイルのコンバート
    grape:/usr/share/mysql/japanese # mv errmsg.sys _errmsg.sys
    grape:/usr/share/mysql/japanese # cat _errmsg.sys | nkf -Ew > errmsg.sys
  4. 自動起動
    インストール時点で、ランレベル235で起動するように設定されています。

最初の設定

  1. /etc/initd/mysql の編集
    デフォルトでは以下のオプションで起動されます。必要がなければ変更する必要はありません。また、これらの変数は my.cnf に記述されていた場合には、my.cnfの内容が優先して使われます。
    変数ディレクトリ説明
    basedir/
    bindir/bin/dirMySQLのインストールディレクトリ
    datadir/var/lib/mysqlデータベースファイルの格納場所
  2. /etc/my.cnf の作成
    1. ひな形をコピーします
      > sudo cp /usr/share/mysql/my-large.cnf /etc/my.cnf
    2. 編集
      基本的にInnodbを有効化して、テーブルに使われるキャラクターセットをUTF-8、表示されるメッセージを日本語にするだけです*1
          24 # The MySQL server
          25 [mysqld]
          …
         120
         121 # Uncomment the following if you are using InnoDB tables
         122 innodb_data_home_dir = /var/lib/mysql/
         123 innodb_data_file_path = ibdata1:1024M:autoextend
         124 innodb_log_group_home_dir = /var/lib/mysql/
         125 innodb_log_arch_dir = /var/lib/mysql/
         126 # You can set .._buffer_pool_size up to 50 - 80 %
         127 # of RAM but beware of setting memory usage too high
         128 innodb_buffer_pool_size = 256M
         129 innodb_additional_mem_pool_size = 20M
         130 # Set .._log_file_size to 25 % of buffer pool size
         131 innodb_log_file_size = 64M
         132 innodb_log_buffer_size = 8M
         133 innodb_flush_log_at_trx_commit = 1
         134 innodb_lock_wait_timeout = 50
         135
         136 # Add by Hondoh
         137 character-set-server=utf8
         138 character-sets-dir=/usr/share/mysql/japanese
         139 default-table-type=InnoDB
         140 skip-character-set-client-handshake
    3. 再起動
      RPMからインストールしたときに入っているゴミ(データベースファイルとデータベースログファイル)を削除してから再起動します。
      # rm /var/lib/mysql/ib_logfile*
      # rm /var/lib/mysql/ibdata*
      # /etc/init.d/mysql restart
  3. mysqlのrootユーザのパスワード設定します。
    # /usr/bin/mysqladmin -u root password '************'
  4. 匿名ユーザとネットワーク経由のrootを削除します
    > mysql -u root -p
    Enter password:
    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 6 to server version: 5.0.19-standard-log
    
    Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
    
    mysql> use mysql;
    Database changed
    mysql> select host,user,password from user;
    +-----------+------+-------------------------------------------+
    | host      | user | password                                  |
    +-----------+------+-------------------------------------------+
    | localhost | root | ***************************************** |
    | grape     | root |                                           |
    | grape     |      |                                           |
    | localhost |      |                                           |
    +-----------+------+-------------------------------------------+
    4 rows in set (0.00 sec)
    
    mysql> delete from user where user='';
    Query OK, 2 rows affected (0.02 sec)
    
    mysql> delete from user where host='grape' and user='root';
    Query OK, 1 row affected (0.00 sec)
    
    mysql> select host,user,password from user;
    +-----------+------+-------------------------------------------+
    | host      | user | password                                  |
    +-----------+------+-------------------------------------------+
    | localhost | root | ***************************************** |
    +-----------+------+-------------------------------------------+
    1 row in set (0.00 sec)
     
    mysql> delete from db where user='';
    Query OK, 2 rows affected (0.01 sec)
     
    mysql> FLUSH PRIVILEGES;
    Query OK, 0 rows affected (0.00 sec)

テスト

# mysql -u root -p
Enter password:************
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2 to server version: 5.0.18-standard-log

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> use test;
Database changed
mysql> show tables;
Empty set (0.00 sec)

mysql> create table books (
    -> isbn int,
    -> title varchar(50),
    -> author varchar(50)
    -> );
Query OK, 0 rows affected (0.01 sec)

mysql> show tables;
+----------------+
| Tables_in_test |
+----------------+
| books          |
+----------------+
1 row in set (0.00 sec)

mysql> insert into books(isbn,title,author) values('1','現代雑兵物語','軍曹');
Query OK, 1 row affected (0.01 sec)

mysql> select * from books;
+------+--------------------+--------+
| isbn | title              | author |
+------+--------------------+--------+
|    1 | 現代雑兵物語 | 軍曹 |
+------+--------------------+--------+
1 row in set (0.00 sec)

mysql> drop table books;
Query OK, 0 rows affected (0.00 sec)

きちんと日本語も通るようです。


Suse 10 Server


*1 それから今度のサーバにはHDDに余裕があるのでデータベースファイルの大きさの初期値を1GBにしました

トップ   編集 凍結 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS   sitemap
Last-modified: 2006-03-12 (日) 00:05:21 (6619d)
Short-URL:
ISBN10
ISBN13
9784061426061