Fedora 10 によるサーバー構築(9):MySQLのインストールと設定

Fedora 10 によるサーバー構築・メニュー

Fedora Core 10 (64bit) でサーバーを構築する。


MySQLのインストールと設定



MySQLのインストール
  1. インストール
  2.  # yum install mysql-server

    以下がインストールされる。

     mysql.x86_64 0:5.0.77-1.fc10            mysql-libs.x86_64 0:5.0.77-1.fc10
     perl-DBD-MySQL.x86_64 0:4.005-8.fc9     perl-DBI.x86_64 0:1.607-1.fc10



MySQLの設定
  1. /etc/my.confの設定
  2. 必要なら、"ft_min_word_len=2"の設定は、全文検索のワードサイズをデフォルトの1文字から2文字に変更する。

     # vi /etc/my.conf

    以下、編集内容。

    [mysqld]
    datadir=/var/lib/mysql
    socket=/var/lib/mysql/mysql.sock
    user=mysql
    # Default to using old password format for compatibility with mysql 3.x
    # clients (those using the mysqlclient10 compatibility package).
    old_passwords=1
    default-character-set=utf8 ← 追加
    
    最後に追加
    [mysql]
    default-character-set=utf8
    ft_min_word_len=2

  3. MySQLの起動・終了・再起動
  4.  # /etc/rc.d/init.d/mysqld start
     # /etc/rc.d/init.d/mysqld stop
     # /etc/rc.d/init.d/mysqld restart

  5. MySQL自動起動設定
  6.  # chkconfig mysqld on

  7. MySQL自動起動設定の確認。ランレベル2〜5がonならOK。
  8.  # chkconfig --list mysqld
     mysqld          0:off   1:off   2:on    3:on    4:on    5:on    6:off

  9. MySQLの初期設定
  10.  # mysql_secure_installation
    
     Enter current password for root (enter for none): ←[Enter]
      :
     Set root password? [Y/n]  ←[Y]
     New password: ← rootパスワード入力
     Re-enter new password: ← rootパスワード入力
     Password updated successfully!
     Reloading privilege tables..
      ... Success!
      :
     Remove anonymous users? [Y/n] ←[Y](匿名ユーザー削除)
      ... Success!
      :
     Disallow root login remotely? [Y/n] ←[Y](リモートからのrootログイン禁止)
      ... Success!
      :
     Remove test database and access to it? [Y/n] ←[Y](testデータベース削除)
      - Dropping test database...
      ... Success!
      - Removing privileges on test database...
      ... Success!
      :
     Reload privilege tables now? [Y/n] ←[Y]
      ... Success!
      :
     Thanks for using MySQL!

  11. ユーザーの作成

  12. MySQLへrootでログインしてユーザーを作成する。

     # mysql -u root -p
    
     mysql> grant select,insert,delete,update,create,drop,file,alter,index on *.* to [user] identified by '[password]';
     mysql> flush privileges;
     mysql> exit