Skip to content

Instantly share code, notes, and snippets.

@goldeneggg
Created July 1, 2012 15:53
Show Gist options
  • Save goldeneggg/3028800 to your computer and use it in GitHub Desktop.
Save goldeneggg/3028800 to your computer and use it in GitHub Desktop.
MySQL5.5インストール on CentOS 6.2

事前準備

% sudo yum -y install cmake bison ncurses-devel

mysql5.5本体インストール

% wget http://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.24.tar.gz/from/http://ftp.iij.ad.jp/pub/db/mysql/
% tar -zxvf mysql-5.5.24.tar.gz
% cd mysql-5.5.24
% cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql-5.5.24 -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DENABLED_LOCAL_INFILE=true -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_EXTRA_CHARSETS=all -DWITH_READLINE=O
% make
% sudo make install

インストール後の設定

% sudo cp support-files/my-medium.cnf /etc/my.cnf

% sudo vi /etc/my.cnf
 ★必要なら[client] [mysqld] のポートを適宜変える
 port = 13406  

 ★文字化け回避設定を [mysqld] セクションへ追記
 character-set-server = utf8

 ★innodb関連オプションを有効化&追加 [mysqld]
 innodb-file-per-table

 ★binlog設定を有効化 [mysqld]
 # Uncomment the following if you want to log updates
 log-bin=mysql-bin

 # binary logging format - mixed recommended
 binlog_format=mixed

 ★ログ設定 [mysqld]
 log-error=/var/log/mysql/error.log
 slow-query-log = 1
 slow-query-log-file = /var/log/mysql/slow-queries.log
 long_query_time = 2
 log-queries-not-using-indexes
 log-slow-admin-statements
 log-output = FILE,TABLE

% sudo groupadd mysql
% sudo useradd -r -g mysql mysql
% cd /usr/local
% sudo chown -R mysql:mysql mysql-5.5.24
% cd mysql-5.5.24
% sudo scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql-5.5.24 --datadir=/usr/local/mysql-5.5.24/data --no-defaults
% sudo chown -R root:root .
% sudo chown -R mysql:mysql data

ディレクトリ作成

% sudo mkdir /var/log/mysql
% sudo chown -R mysql:mysql /var/log/mysql

サービス化・起動・確認・停止

% sudo cp support-files/mysql.server /etc/init.d/   
% sudo /etc/init.d/mysql.server start
% /usr/local/mysql-5.5.24/bin/mysqladmin -u root password "XXXX"
% /usr/local/mysql-5.5.24/bin/mysql -u root -p
 mysql> show databases;
 +--------------------+
 | Database           |
 +--------------------+
 | information_schema |
 | mysql              |
 | performance_schema |
 | test               |
 +--------------------+
 4 rows in set (0.00 sec)
% sudo /etc/init.d/mysql.server stop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment