• MySQL-rootユーザーにパスワードを設定する

    MySQLのrootユーザーにパスワードを設定する。
    
    
    # mysqladmin -u root password "<新しいパスワード>"
    #

  • MySQLのインストール (yum)

    yumを使ってCentOSにMySQLをインストールします。

    ・MySQLサーバーとクライアントをインストールします。

    # yum install -y mysql mysql-server

    ・/etc/my.cnf 編集

    01
    02
    03
    04
    05
    06
    07
    08
    09
    10
    11
    12
    13
    14
    15
    [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
     
    # Disabling symbolic-links is recommended to prevent assorted security risks;
    # to do so, uncomment this line:
    # symbolic-links=0
     
    [mysqld_safe]
    log-error=/var/log/mysqld.log
    pid-file=/var/run/mysqld/mysqld.pid
    ↓文字化け対策のため2行追加
    
    01
    02
    03
    04
    05
    06
    07
    08
    09
    10
    11
    12
    13
    14
    15
    16
    17
    18
    [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  # デフォルトのキャラセットをutf8に設定
    skip-character-set-client-handshake  # 余計な文字コード変換しない
     
    # Disabling symbolic-links is recommended to prevent assorted security risks;
    # to do so, uncomment this line:
    # symbolic-links=0
     
    [mysqld_safe]
    log-error=/var/log/mysqld.log
    pid-file=/var/run/mysqld/mysqld.pid

    ・MySQLサーバー起動

    # service mysqld start

    ・OS起動時にMySQLも起動する。

    # chkconfig mysqld on

    [/text]