end0tknr's kipple - web写経開発

太宰府天満宮の狛犬って、妙にカワイイ

mysql5.7 をsrcからinstall

end0tknr.hateblo.jp

以前、↑こちらで mysql5.5をinstallしましたが、5.7では少々異なりましたので

install mysql 5.7

$ wget http://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.14.tar.gz
$ tar -xvf mysql-5.7.14.tar.gz
$ cd mysql-5.7.14
$ cmake . \
   -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
   -DDEFAULT_CHARSET=utf8 \
   -DDEFAULT_COLLATION=utf8_general_ci \
   -DENABLED_LOCAL_INFILE=true \
   -DWITH_INNOBASE_STORAGE_ENGINE=1 \
   -DWITH_EXTRA_CHARSETS=all \
   -DWITH_READLINE=ON
  :
CMake Error at cmake/boost.cmake:81 (MESSAGE):
  You can download it with -DDOWNLOAD_BOOST=1 -DWITH_BOOST=<directory>

  This CMake script will look for boost in <directory>.  If it is not there,
  it will download and unpack it (in that directory) for you.

  If you are inside a firewall, you may need to use an http proxy:

  export http_proxy=http://example.com:80

Call Stack (most recent call first):
  cmake/boost.cmake:238 (COULD_NOT_FIND_BOOST)
  CMakeLists.txt:455 (INCLUDE)
-- Configuring incomplete, errors occurred!

mysql5.7よりboostが必要になったようです。

そこで、cmakeのoptionに 「-DDOWNLOAD_BOOST=1 -DWITH_BOOST=/home/endo/tmp/」を追加すると boostを勝手にdownloadしてくれます。

cmake . \
   -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
   -DDEFAULT_CHARSET=utf8 \
   -DDEFAULT_COLLATION=utf8_general_ci \
   -DENABLED_LOCAL_INFILE=true \
   -DWITH_INNOBASE_STORAGE_ENGINE=1 \
   -DWITH_EXTRA_CHARSETS=all \
   -DWITH_READLINE=ON \
   -DDOWNLOAD_BOOST=1 \
   -DWITH_BOOST=/home/endo/tmp/

$ make
$ make test
# make install

edit /etc/my.conf

ポイントは - skip-grant-tables がないと、id/pw=root/null でログインできません - sql-mode="ONLY_FULL_GROUP_BY" となっていると、selectする全colをgroup by で指定する必要があります

# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
# *** default location during install, and will be replaced if you
# *** upgrade to a newer version of MySQL.

[mysqld]

# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M

# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin

# These are commonly set, remove the # and set as required.
# basedir = .....
# datadir = .....
# port = .....
# server_id = .....
# socket = .....
default-storage-engine = INNODB
basedir = /usr/local/mysql
datadir = /home/mysql/data
port            = 3306
socket          = /tmp/mysql.sock

skip-grant-tables
#sql-mode="ONLY_FULL_GROUP_BY"
sql-mode=""

# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M 

# sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES 


# max connections
max_connections = 64
# table_open_cache = (max_connections * tables used in one transaction) + alpha
table_open_cache = 800
# table_definition_cache = (all tables in mysql + max_connections) + alpha
table_definition_cache = 400
# open_files_limit = table_open_cache * 1.4
open_files_limit = 1120
 
# global buffer
key_buffer_size = 16M
query_cache_type = 0
# innodb_buffer_pool_size = RAM for Mysql * 0.7
innodb_buffer_pool_size = 256M
 
# thread buffer
read_buffer_size = 256K
read_rnd_buffer_size = 512K
join_buffer_size = 256K
sort_buffer_size = 512K
 
# InnoDB
innodb_file_per_table
innodb_autoextend_increment = 64
innodb_log_files_in_group = 2
innodb_log_file_size = 64M
innodb_log_buffer_size = 16M
innodb_flush_log_at_trx_commit = 1
innodb_flush_neighbors=0
#innodb_flush_method=O_DIRECT
innodb_thread_concurrency = 4
innodb_commit_concurrency = 4
 
# log
general_log = 0
general_log_file = /usr/local/var/mysql/general.log
slow_query_log = 0
 
[mysqldump]
#max_allowed_packet = 16M
quick
set-charset
single-transaction