[MySQL][5.6.14]インストール

環境

インストールを行った環境は、以下の通りです。

  • OS:CentOS 6.8

インストールするものは、以下です。

  • MySQL 5.6.14

MySQLのインストール

インストールパターン

MySQLのインストールには、

  • ソースファイルからコンパイルしてインストール
  • バイナリtar-ballからインストール
  • rpmでインストール

という3パターンがあります。

個人的には、バイナリtar-ballでインストールするほうがバージョンアップなどの際に対応しやすい気がしているので、今回はこの方法でインストールします。

ダウンロード

MySQLのサイトから、インストールファイルをダウンロードしてきます。
インストール先のOSはCentOSなので、
http://dev.mysql.com/downloads/mysql/#downloads」へアクセスして、Linux用のパッケージファイルをダウンロードしてきます。
「Linux – Generic (glibc 2.5) (x86, 64-bit), Compressed TAR Archive」は全部入りのアーカイブですので、ひとまずこれをダウンロードしておきます。

ダウンロードしたファイル「mysql-5.6.14-linux-glibc2.5-x86_64.tar.gz」は、インストールしたいLinuxへ転送しておきます。

ちなみに、wgetでもダウンロードはできます。

$ wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.14-linux-glibc2.5-x86_64.tar.gz

グループとユーザの作成

MySQLをインストールする前に、まずはmysqlグループとmysqlユーザを作成しておきます。
以下のように作成しました。

# groupadd mysql
# useradd -r -g mysql mysql

# grep mysql /etc/group
mysql:x:501:
# grep mysql /etc/passwd
mysql:x:501:501::/home/mysql:/bin/bash

ファイルの展開

ダウンロードしたバイナリファイルを展開します。
インストール先は「/usr/local」とするので、ファイルを/usr/localへ移動させてから展開し、シンボリックリンク「/usr/local/mysql」を作成します。

# cd /usr/local
# tar zxvf /home/UserName/mysql-5.6.14-linux-glibc2.5-x86_64.tar.gz
# ln -s /usr/local/mysql-5.6.14-linux-glibc2.5-x86_64 mysql

初期設定

続いて、ファイルやディレクトリの所有者を変更します。

# cd mysql
# chown -R mysql .
# chgrp -R mysql .

続いて、初期インストールスクリプトを実行しておきます。

# scripts/mysql_install_db --user=mysql
Installing MySQL system tables...2013-09-29 20:57:53 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated.
Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2013-09-29 20:57:53 2158 [Note] InnoDB: The InnoDB memory heap is disabled
2013-09-29 20:57:53 2158 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2013-09-29 20:57:53 2158 [Note] InnoDB: Compressed tables use zlib 1.2.3
2013-09-29 20:57:53 2158 [Note] InnoDB: Using Linux native AIO
2013-09-29 20:57:53 2158 [Note] InnoDB: Using CPU crc32 instructions
2013-09-29 20:57:53 2158 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2013-09-29 20:57:53 2158 [Note] InnoDB: Completed initialization of buffer pool
2013-09-29 20:57:53 2158 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
2013-09-29 20:57:53 2158 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB
2013-09-29 20:57:53 2158 [Note] InnoDB: Database physically writes the file full: wait...
2013-09-29 20:57:53 2158 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
2013-09-29 20:57:53 2158 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
2013-09-29 20:57:54 2158 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2013-09-29 20:57:54 2158 [Warning] InnoDB: New log files created, LSN=45781
2013-09-29 20:57:54 2158 [Note] InnoDB: Doublewrite buffer not found: creating new
2013-09-29 20:57:54 2158 [Note] InnoDB: Doublewrite buffer created
2013-09-29 20:57:54 2158 [Note] InnoDB: 128 rollback segment(s) are active.
2013-09-29 20:57:54 2158 [Warning] InnoDB: Creating foreign key constraint system tables.
2013-09-29 20:57:54 2158 [Note] InnoDB: Foreign key constraint system tables created
2013-09-29 20:57:54 2158 [Note] InnoDB: Creating tablespace and datafile system tables.
2013-09-29 20:57:54 2158 [Note] InnoDB: Tablespace and datafile system tables created.
2013-09-29 20:57:54 2158 [Note] InnoDB: Waiting for purge to start
2013-09-29 20:57:54 2158 [Note] InnoDB: 5.6.14 started; log sequence number 0
2013-09-29 20:57:54 2158 [Note] Binlog end
2013-09-29 20:57:54 2158 [Note] InnoDB: FTS optimize thread exiting.
2013-09-29 20:57:54 2158 [Note] InnoDB: Starting shutdown...
2013-09-29 20:57:56 2158 [Note] InnoDB: Shutdown completed; log sequence number 1625977
OK

Filling help tables...2013-09-29 20:57:56 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated.
Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2013-09-29 20:57:56 2181 [Note] InnoDB: The InnoDB memory heap is disabled
2013-09-29 20:57:56 2181 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2013-09-29 20:57:56 2181 [Note] InnoDB: Compressed tables use zlib 1.2.3
2013-09-29 20:57:56 2181 [Note] InnoDB: Using Linux native AIO
2013-09-29 20:57:56 2181 [Note] InnoDB: Using CPU crc32 instructions
2013-09-29 20:57:56 2181 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2013-09-29 20:57:56 2181 [Note] InnoDB: Completed initialization of buffer pool
2013-09-29 20:57:56 2181 [Note] InnoDB: Highest supported file format is Barracuda.
2013-09-29 20:57:56 2181 [Note] InnoDB: 128 rollback segment(s) are active.
2013-09-29 20:57:56 2181 [Note] InnoDB: Waiting for purge to start
2013-09-29 20:57:56 2181 [Note] InnoDB: 5.6.14 started; log sequence number 1625977
2013-09-29 20:57:56 2181 [Note] Binlog end
2013-09-29 20:57:56 2181 [Note] InnoDB: FTS optimize thread exiting.
2013-09-29 20:57:56 2181 [Note] InnoDB: Starting shutdown...
2013-09-29 20:57:58 2181 [Note] InnoDB: Shutdown completed; log sequence number 1625987
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

./bin/mysqladmin -u root password 'new-password'
./bin/mysqladmin -u root -h www9010ui.sakura.ne.jp password 'new-password'

Alternatively you can run:

./bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:

cd . ; ./bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl

cd mysql-test ; perl mysql-test-run.pl

Please report any problems with the ./bin/mysqlbug script!

The latest information about MySQL is available on the web at

Support MySQL by buying support/licenses at http://shop.mysql.com New default config file was created as ./my.cnf and will be used by default by the server when you start it. You may edit this file to change server settings

最後に、ディレクトリとファイルの所有ユーザを変更しておきます。

# chown -R root .
# chown -R mysql data

共有ライブラリの設定

インストール後、MySQLの共有ライブラリを利用できるように、パスを追加しておきます。

/etc/ld.so.confを以下のように修正します。

# cat "/usr/local/mysql/lib/" >> /etc/ld.so.conf
# cat /etc/ld.so.conf
※末尾に「/usr/local/net-snmp/lib/」が追記されていればOK

ld.so.confを修正したら、ldconfigコマンドで再読み込みさせておきます。

# ldconfig

MySQLの起動

起動スクリプトの準備と自動起動設定

続いて、MySQLの起動スクリプトを準備します。
バイナリtar-ballには起動スクリプトが用意されているので、それを使います。

# pwd
/usr/local/mysql
# cp -i support-files/mysql.server /etc/init.d/mysql
# chkconfig --list | grep mysql
(なにも表示されない)
# chkconfig mysql on
# chkconfig --list | grep mysql
mysql 0:off 1:off 2:on 3:on 4:on 5:on 6:off

設定ファイルの作成

ひとまず、最低限の設定を書いておきます。

設定ファイルは「my.cnf」ですが、どこに配置すればいいかをヘルプで確認してみると、以下のような記述がありました。

Default options are read from the following files in the given order:
/etc/my.cnf /etc/mysql/my.cnf /usr/local/mysql/etc/my.cnf ~/.my.cnf

/etc/my.cnf → /etc/mysql/my.cnf → /usr/local/mysql/etc/my.cnf → ~/.my.cnf という順番で探していくようですね。
一般的には /etc/my.cnf が多いのではないでしょうか。
今回も /etc/my.cnf にしました。

以下の感じでどうかなと思いますが、必要に応じて適宜書き換えてください。

[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

[client]
socket=/var/lib/mysql/mysql.sock

起動!

では、起動させてみましょう。
起動スクリプトを使った起動・停止ですので、serviceコマンドで操作できます。

# service mysql start
Starting MySQL. SUCCESS!

無事に起動しました。
続いて、初期設定を行っていきます。

スポンサーリンク

シェアする

  • このエントリーをはてなブックマークに追加

フォローする

スポンサーリンク