MySQL5.7 を CentOS6 にソースからインストール

estis2015/10/25 (日) 15:00 に投稿

Cent0S6 最小構成にソースインストール

参考URL
https://dev.mysql.com/doc/refman/5.7/en/installing-source-distribution…

システムユーザー mysql 作成

# groupadd mysql
# useradd -r -g mysql mysql

必要なものを事前にインストール
(まとめて書いているけれど、初回試行錯誤の賜物。gcc* は、手抜き重視のため)

# yum install cmake
# yum install gcc*
# yum install git
# yum install ncurses-devel
# yum install bison

ソースダウンロード

# cd /usr/local/src/
# wget http://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.9.tar.gz
# tar xvzf mysql-5.7.9.tar.gz

コンパイル & インストール
(yum でインストールされる boost は、バージョン 1.41.0 だが、バージョン 1.59.0 以上が必要なので、「-DDOWNLOAD_BOOST=1 -DWITH_BOOST=/usr/local/src」を指定)

# cd mysql-5.7.9
# cmake . -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/usr/local/src/
# make
# make install

MySQL初期化

# cd /usr/local/mysql/
# chown -R mysql:mysql .
# bin/mysqld --initialize --user=mysql
2015-10-25T03:55:03.675860Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2015-10-25T03:55:04.459528Z 0 [Warning] InnoDB: New log files created, LSN=45790
2015-10-25T03:55:04.560041Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2015-10-25T03:55:04.623188Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 2caeb267-7acc-11e5-b458-18205754a232.
2015-10-25T03:55:04.624554Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2015-10-25T03:55:04.625533Z 1 [Note] A temporary password is generated for root@localhost: Z?lphfPB+99R

※ mysql_install_db は使用されなくなった。
  [WARNING] mysql_install_db is deprecated. Please consider switching to mysqld --initialize
一時パスワードが、標準出力に表示されていることに注意!

初期化、続き

# bin/mysql_ssl_rsa_setup 
# chown -R root .
# chown -R mysql data

MySQL起動

# bin/mysqld_safe  --user=mysql &
# bin/mysql -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.9

Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> \s
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

起動し、ログインできるが、パスワード変更が必要なので、
ALTER USER で変更

mysql>  ALTER USER 'root'@'localhost' IDENTIFIED BY 'New Passward;


mysql> \s
--------------
mysql  Ver 14.14 Distrib 5.7.9, for Linux (x86_64) using  EditLine wrapper

Connection id:		2
Current database:	
Current user:		root@localhost
SSL:			Not in use
Current pager:		stdout
Using outfile:		''
Using delimiter:	;
Server version:		5.7.9
Protocol version:	10
Connection:		Localhost via UNIX socket
Server characterset:	latin1
Db     characterset:	latin1
Client characterset:	utf8
Conn.  characterset:	utf8
UNIX socket:		/tmp/mysql.sock
Uptime:			46 min 20 sec

Threads: 1  Questions: 8  Slow queries: 0  Opens: 106  Flush tables: 1  Open tables: 99  Queries per second avg: 0.002
--------------

取りあえずインストールは完了。