1. ソースからインストール
  2. 設定
  3. 初期化・起動
  4. エラー・警告


ソースからインストール

CentOS 7.1 に、MySQL 5.6.25をソースからインストールします。

設定

初期化・起動

  • 初期化

  • MySQLをインストール後、データベースの初期化が必要です。 初期化は、オプションでデータディレクトリやユーザーなどを指定して、 ソースディレクトリのscripts/mysql_install_dbを実行します。 今回は、以下の3つのオプションを指定しました。

    --user=mysql
    --datadir=/var/lib/mysql
    --basedir=/usr/local/mysql
    参考

    実行結果は以下のようになります。

    # /usr/local/mysql/scripts/mysql_install_db \
    > --user=mysql \
    > --datadir=/var/lib/mysql \
    > --basedir=/usr/local/mysql
    Installing MySQL system tables...2015-07-04 23:18:47 0 [Warning] TIMESTAMP with
    implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timest
    amp server option (see documentation for more details).
    2015-07-04 23:18:47 0 [Note] /usr/local/mysql/bin/mysqld (mysqld 5.6.25) starti
    ng as process 2340 ...
    2015-07-04 23:18:47 2340 [Note] InnoDB: Using atomics to ref count buffer pool p
    ages
    2015-07-04 23:18:47 2340 [Note] InnoDB: The InnoDB memory heap is disabled
    2015-07-04 23:18:47 2340 [Note] InnoDB: Mutexes and rw_locks use GCC atomic buil
    tins
    2015-07-04 23:18:47 2340 [Note] InnoDB: Memory barrier is not used
    2015-07-04 23:18:47 2340 [Note] InnoDB: Compressed tables use zlib 1.2.3
    2015-07-04 23:18:47 2340 [Note] InnoDB: Not using CPU crc32 instructions
    2015-07-04 23:18:47 2340 [Note] InnoDB: Initializing buffer pool, size = 128.0M
    2015-07-04 23:18:47 2340 [Note] InnoDB: Completed initialization of buffer pool
    2015-07-04 23:18:47 2340 [Note] InnoDB: Highest supported file format is Barracu
    da.
    2015-07-04 23:18:48 2340 [Note] InnoDB: 128 rollback segment(s) are active.
    2015-07-04 23:18:48 2340 [Note] InnoDB: Waiting for purge to start
    2015-07-04 23:18:48 2340 [Note] InnoDB: 5.6.25 started; log sequence number 1625
    987
    2015-07-04 23:18:48 2340 [Note] Binlog end
    2015-07-04 23:18:48 2340 [Note] InnoDB: FTS optimize thread exiting.
    2015-07-04 23:18:48 2340 [Note] InnoDB: Starting shutdown...
    2015-07-04 23:18:49 2340 [Note] InnoDB: Shutdown completed; log sequence number
    1625997
    OK
    
    Filling help tables...2015-07-04 23:18:49 0 [Warning] TIMESTAMP with implicit DE
    FAULT value is deprecated. Please use --explicit_defaults_for_timestamp server o
    ption (see documentation for more details).
    2015-07-04 23:18:49 0 [Note] /usr/local/mysql/bin/mysqld (mysqld 5.6.25) startin
    g as process 2363 ...
    2015-07-04 23:18:49 2363 [Note] InnoDB: Using atomics to ref count buffer pool p
    ages
    2015-07-04 23:18:49 2363 [Note] InnoDB: The InnoDB memory heap is disabled
    2015-07-04 23:18:49 2363 [Note] InnoDB: Mutexes and rw_locks use GCC atomic buil
    tins
    2015-07-04 23:18:49 2363 [Note] InnoDB: Memory barrier is not used
    2015-07-04 23:18:49 2363 [Note] InnoDB: Compressed tables use zlib 1.2.3
    2015-07-04 23:18:49 2363 [Note] InnoDB: Not using CPU crc32 instructions
    2015-07-04 23:18:49 2363 [Note] InnoDB: Initializing buffer pool, size = 128.0M
    2015-07-04 23:18:49 2363 [Note] InnoDB: Completed initialization of buffer pool
    2015-07-04 23:18:49 2363 [Note] InnoDB: Highest supported file format is Barracu
    da.
    2015-07-04 23:18:49 2363 [Note] InnoDB: 128 rollback segment(s) are active.
    2015-07-04 23:18:49 2363 [Note] InnoDB: Waiting for purge to start
    2015-07-04 23:18:49 2363 [Note] InnoDB: 5.6.25 started; log sequence number 1625
    997
    2015-07-04 23:18:49 2363 [Note] Binlog end
    2015-07-04 23:18:49 2363 [Note] InnoDB: FTS optimize thread exiting.
    2015-07-04 23:18:49 2363 [Note] InnoDB: Starting shutdown...
    2015-07-04 23:18:51 2363 [Note] InnoDB: Shutdown completed; log sequence number
    1626007
    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:
    
      /usr/local/mysql/bin/mysqladmin -u root password 'new-password'
      /usr/local/mysql/bin/mysqladmin -u root -h centos7.localdomain password '
      new-password'
    
    Alternatively you can run:
    
      /usr/local/mysql/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 . ; /usr/local/mysql/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 at http://bugs.mysql.com/
    
    The latest information about MySQL is available on the web at
    
      http://www.mysql.com
    
    Support MySQL by buying support/licenses at http://shop.mysql.com
    
    WARNING: Found existing config file /usr/local/mysql/my.cnf on the system.
    Because this file might be in use, it was not replaced,
    but was used in bootstrap (unless you used --defaults-file)
    and when you later start the server.
    The new default config file was created as /usr/local/mysql/my-new.cnf,
    please compare it with your file and take the changes you need.
    
    WARNING: Default config file /etc/my.cnf exists on the system
    This file will be read by default by the MySQL server
    If you do not want to use this, either remove it, or use the
    --defaults-file argument to mysqld_safe when starting the server

    basedir

    Red Hat Enterprise Linux 7用rpmからインストールした場合、 MySQLは/usr/local/mysql/以下にインストールされるので、 --basedirは以下のようになります。。

    --basedir=/usr/local/mysql

    datadir

    --datadir ではmy.cnfのdatadirで指定したのパスを指定します。

    --datadir=/var/lib/mysql

  • 起動

  • systemctlで起動してみます。

    # systemctl start mysqld

    何も表示されなければ正常に起動しているはずで、psコマンドで確認すると以下のようになります。

    # ps ax | grep mysql
     2706 ?        S      0:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/v
     ar/lib/mysql --pid-file=/var/lib/mysql/centos7.localdomain.pid
     2870 ?        Sl     0:00 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysq
     l --datadir=/var/lib/mysql --plugin-dir=/usr/local/mysql/lib/plugin --user=mysq
       --log-error=/var/log/mysqld.log --pid-file=/var/lib/mysql/centos7.localdomain
       .pid --socket=/var/lib/mysql/mysql.sock
     2894 pts/0    R+     0:00 grep --color=auto mysql

  • 接続テスト

  • mysqlコマンドで接続テストを行います。

    # /usr/local/mysql/bin/mysql -u root
    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 1
    Server version: 5.6.25 Source distribution
    
    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.

    接続できない場合は、以下を参考に設定やオプションを確認します。

エラー・警告

  • Could NOT find Curses

  • -- Could NOT find Curses (missing:  CURSES_LIBRARY CURSES_IN
    CLUDE_PATH)
    CMake Error at cmake/readline.cmake:85 (MESSAGE):
      Curses library not found.  Please install appropriate package,
    
          remove CMakeCache.txt and rerun cmake.On Debian/Ubuntu, package name is li
          bncurses5-dev, on Redhat and derivates it is ncurses-devel.
    Call Stack (most recent call first):
      cmake/readline.cmake:128 (FIND_CURSES)
      cmake/readline.cmake:202 (MYSQL_USE_BUNDLED_EDITLINE)
      CMakeLists.txt:409 (MYSQL_CHECK_EDITLINE)
    
    
    -- Configuring incomplete, errors occurred!
    CentOSの場合 ncurses-develがインストールされていないと、上記のエラーになります。 現状を確認すると以下のようになっていました。
    # yum list ncurses*
    ...
    インストール済みパッケージ
    ncurses.x86_64                      5.9-13.20130511.el7                @anaconda
    ncurses-base.noarch                 5.9-13.20130511.el7                @anaconda
    ncurses-libs.x86_64                 5.9-13.20130511.el7                @anaconda
    利用可能なパッケージ
    ncurses-devel.i686                  5.9-13.20130511.el7                base
    ncurses-devel.x86_64                5.9-13.20130511.el7                base
    ncurses-libs.i686                   5.9-13.20130511.el7                base
    ncurses-static.i686                 5.9-13.20130511.el7                base
    ncurses-static.x86_64               5.9-13.20130511.el7                base
    ncurses-term.noarch                 5.9-13.20130511.el7                base
    ncurses-develがインストールされていないのでyumでインストールします。

    インストール後、以下のようにファイル(cmakeのキャッシュファイル?)を削除して、再度cmakeを実行します。

    rm CMakeCache.txt

  • Googlemockダウンロードエラー

  • オプション "-DENABLE_DOWNLOADS=1"を付けて実行したときに、 Googlemockのダウンロードでタイムアウトが発生する場合

     # 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 \
       -DENABLE_DOWNLOADS=1
    ...
    ...
    -- Library mysqlclient depends on OSLIBS -lpthread;m;dl
    -- Download failed, error: 28;"Timeout was reached"
    -- To enable google test, please download http://googlemock.googlecode.com/files
    /gmock-1.6.0.zip to the directory /root/rpmbuild/SOURCES/mysql-5.6.25/source_dow
    nloads
    -- If you are inside a firewall, you may need to use an http proxy: export http_
    proxy=http://example.com:80
    ...
    -- Configuring done
    -- Generating done
    -- Build files have been written to: /root/rpmbuild/SOURCES/mysql-5.6.25
    firewallが有効でないか確認します。有効の場合は停止します。 CentOS 7では、以下のコマンドで停止できます。
     # systemctl stop firewalld

  • WIDTH_READLINEオプション

  • 5.6.25では、オプション -DWITH_READLINE を指定すると以下のような警告がでます。

    # cmake -DWITH_READLINE=OFF ...
    ...
    ...
    -- Configuring done
    -- Generating done
    CMake Warning:
      Manually-specified variables were not used by the project:
    
        WITH_READLINE
    
    
    -- Build files have been written to: /root/rpmbuild/SOURCES/mysql-5.6.25
    以下で確認すると、5.6.5から削除されたようです。

    2.9.4 MySQL Source-Configuration Options