環境準備:
mysql 安裝包:mysql-5.7.17.tar.gz
軟體下載下傳 :http://mirrors.sohu.com/mysql/MySQL-5.7/
yum源:
<code>[root@web_1 ~]</code><code># cat /etc/yum.repos.d/server.repo </code>
<code>[</code><code>local</code><code>]</code>
<code>name=</code><code>local</code>
<code>baseurl=</code><code>file</code><code>:</code><code>///mnt/cdrom</code>
<code>gpgcheck=0</code>
<code>enabled=1</code>
<code>[root@web_1 ~]</code><code>#</code>
系統版本:
<code>[root@web_1 ~]</code><code># cat /etc/redhat-release </code>
<code>CentOS Linux release 7.2.1511 (Core) </code>
<code>[root@web_1 ~]</code><code># uname -r</code>
<code>3.10.0-327.el7.x86_64</code>
安裝依賴包:
<code>[root@web_1 mysql-5.7.17]</code><code># yum install -y libaio-devel ncurses-devel cmake gcc-c++ bison</code>
建立使用者及解壓:
<code>[root@web_1 mysql-5.7.17]</code><code># useradd -s /sbin/nologin -M mysql</code>
<code>[root@web_1 mysql-5.7.17]</code><code>#mkdir -p /data/3307/data</code>
<code>[root@web_1 mysql-5.7.17]</code><code># tar xf mysql-5.7.17.tar.gz </code>
<code>[root@web_1 mysql-5.7.17]</code><code># cd mysql-5.7.17/</code>
編譯安裝:
<code>[root@web_1 mysql-5.7.17]</code><code># cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql-5.7.17/ -DMYSQL_DATADIR=/usr/local/mysql-5.7.17/data -DMYSQL_UNIX_ADDR=/usr/local/mysql-5.7.17/tmp/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DEXTRA_CHARSETS=gbk,gb2312,utf8,ascii -DENABLED_LOOCAL_INFILE=ON -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_FEDERATED_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 -DWITHOUT_PARRTITION_STORAGE_ENGINE=1 -DWITH_FAST_MUTEXES=1 -DWITH_ZLIB=bundled -DENABLED_LOCAL_INFILE=1 -DWITH_READLINE=1 -DWITH_EMBEDDED_SERVER=1-DWITH_DEBUG=0</code>
<code>-- Running cmake version 2.8.11</code>
<code>-- Could NOT </code><code>find</code> <code>Git (missing: GIT_EXECUTABLE) </code>
<code>-- Configuring with MAX_INDEXES = 64U</code>
<code>-- SIZEOF_VOIDP 8</code>
<code>-- MySQL 5.7.17</code>
<code>-- Packaging as: mysql-5.7.17-Linux-x86_64</code>
<code>-- Looked </code><code>for</code> <code>boost</code><code>/version</code><code>.hpp </code><code>in</code> <code>and </code>
<code>-- BOOST_INCLUDE_DIR BOOST_INCLUDE_DIR-NOTFOUND</code>
<code>-- LOCAL_BOOST_DIR </code>
<code>-- LOCAL_BOOST_ZIP </code>
<code>-- Could not </code><code>find</code> <code>(the correct version of) boost.</code>
<code>-- MySQL currently requires boost_1_59_0</code>
<code>CMake Error at cmake</code><code>/boost</code><code>.cmake:81 (MESSAGE):</code>
<code> </code><code>You can download it with -DDOWNLOAD_BOOST=1 -DWITH_BOOST=<directory></code>
<code> </code><code>This CMake script will </code><code>look</code> <code>for</code> <code>boost </code><code>in</code> <code><directory>. If it is not there,</code>
<code> </code><code>it will download and unpack it (</code><code>in</code> <code>that directory) </code><code>for</code> <code>you.</code>
<code> </code><code>If you are inside a firewall, you may need to use an http proxy:</code>
<code> </code><code>export</code> <code>http_proxy=http:</code><code>//example</code><code>.com:80</code>
<code>Call Stack (most recent call first):</code>
<code> </code><code>cmake</code><code>/boost</code><code>.cmake:238 (COULD_NOT_FIND_BOOST)</code>
<code> </code><code>CMakeLists.txt:455 (INCLUDE)</code>
<code>-- Configuring incomplete, errors occurred!</code>
編譯報錯!!!!!
從标出的紅色部分可以看出是缺少依賴google一番後 找到解決方案
mysql5.7.5以後都需要 boost
安裝boost:
<code>[root@web_1 mysql-5.7.17]</code><code># tar -xf boost_1_59_0.tar.gz</code>
<code>[root@web_1 mysql-5.7.17]</code><code># cd boost_1_59_0/</code>
<code>[root@web_1 mysql-5.7.17]</code><code># mkdir /usr/local/boost</code>
<code>[root@web_1 mysql-5.7.17]</code><code># cp -a ./* /usr/local/boost/</code>
再次編譯(指定boost路徑):
#增加了boost路徑 -DWITH_BOOST
<code>[root@web_1 mysql-5.7.17]</code><code># cmake \</code>
<code>-DCMAKE_INSTALL_PREFIX=</code><code>/usr/local/mysql</code> <code>\</code>
<code>-DMYSQL_DATADIR=</code><code>/data/3307/data</code> <code>\ </code><code>#自定義目錄</code>
<code>-DSYSCONFDIR=</code><code>/data/3307</code> <code>\ </code><code>#自定義目錄</code>
<code>-DMYSQL_USER=mysql \</code>
<code>-DWITH_MYISAM_STORAGE_ENGINE=1 \</code>
<code>-DWITH_INNOBASE_STORAGE_ENGINE=1 \</code>
<code>-DWITH_ARCHIVE_STORAGE_ENGINE=1 \</code>
<code>-DWITH_MEMORY_STORAGE_ENGINE=1 \</code>
<code>-DWITH_READLINE=1 \</code>
<code>-DMYSQL_UNIX_ADDR=</code><code>/data/3307/mysql</code><code>.sock \ </code><code>#自定義目錄</code>
<code>-DMYSQL_TCP_PORT=3307 \ </code><code>#自定義端口</code>
<code>-DENABLED_LOCAL_INFILE=1 \</code>
<code>-DENABLE_DOWNLOADS=1 \</code>
<code>-DWITH_PARTITION_STORAGE_ENGINE=1 \</code>
<code>-DEXTRA_CHARSETS=all \</code>
<code>-DDEFAULT_CHARSET=utf8 \</code>
<code>-DDEFAULT_COLLATION=utf8_general_ci \</code>
<code>-DWITH_DEBUG=0 \</code>
<code>-DMYSQL_MAINTAINER_MODE=0 \</code>
<code>-DWITH_SSL:STRING=bundled \</code>
<code>-DWITH_ZLIB:STRING=bundled \</code>
<code>-DWITH_BOOST=</code><code>/usr/local/boost</code>
<code>[root@web_1 mysql-5.7.17]</code><code># make && make install</code>
make過程中報以下錯誤!!!
<code>[ 75%] Built target sqlgunitlib</code>
<code>[ 75%] Building CXX object unittest</code><code>/gunit/CMakeFiles/merge_small_tests-t</code><code>.</code><code>dir</code><code>/merge_small_tests</code><code>.cc.o</code>
<code>c++: internal compiler error: Killed (program cc1plus)</code>
<code>Please submit a full bug report,</code>
<code>with preprocessed </code><code>source</code> <code>if</code> <code>appropriate.</code>
<code>See <http:</code><code>//bugzilla</code><code>.redhat.com</code><code>/bugzilla</code><code>> </code><code>for</code> <code>instructions.</code>
<code>make</code><code>[2]: *** [unittest</code><code>/gunit/CMakeFiles/merge_small_tests-t</code><code>.</code><code>dir</code><code>/merge_small_tests</code><code>.cc.o] Error 4</code>
<code>make</code><code>[1]: *** [unittest</code><code>/gunit/CMakeFiles/merge_small_tests-t</code><code>.</code><code>dir</code><code>/all</code><code>] Error 2</code>
<code>make</code><code>: *** [all] Error 2</code>
google一番後發現是 記憶體不夠 swap分區也不夠
解決方案:
<code>[root@web_1 ~]</code><code># dd if=/dev/zero of=/swapfile bs=1k count=2048000 </code>
<code>[root@web_1 ~]</code><code># mkswap /swapfile </code>
<code>[root@web_1 ~]</code><code># swapon /swapfile</code>
初始化:
<code>[root@web_1 3307]</code><code># mysqld --defaults-file=/data/3307/my.cnf --initialize-insecure --user=mysql</code>
啟動服務:
<code>[root@web_1 3307]</code><code># mysqld_safe --user=mysql &</code>
<code>[root@web_1 data]</code><code># mysql -uroot</code>
<code>Welcome to the MySQL monitor. Commands end with ; or \g.</code>
<code>Your MySQL connection </code><code>id</code> <code>is 3</code>
<code>Server version: 5.7.17-log Source distribution</code>
<code>Copyright (c) 2000, 2016, Oracle and</code><code>/or</code> <code>its affiliates. All rights reserved.</code>
<code>Oracle is a registered trademark of Oracle Corporation and</code><code>/or</code> <code>its</code>
<code>affiliates. Other names may be trademarks of their respective</code>
<code>owners.</code>
<code>Type </code><code>'help;'</code> <code>or </code><code>'\h'</code> <code>for</code> <code>help. Type </code><code>'\c'</code> <code>to </code><code>clear</code> <code>the current input statement.</code>
<code>mysql> show databases;</code>
<code>+--------------------+</code>
<code>| Database |</code>
<code>| information_schema |</code>
<code>| mysql |</code>
<code>| performance_schema |</code>
<code>| sys |</code>
<code>4 rows </code><code>in</code> <code>set</code> <code>(0.00 sec)</code>
<code>mysql></code>
安裝完成!
本文轉自 chaunceyjiang 51CTO部落格,原文連結:http://blog.51cto.com/cqwujiang/1900875,如需轉載請自行聯系原作者