关于从源码包安装MySQL,官方对此有详细的说明文档,具体位置:
http://dev.mysql.com/doc/refman/5.7/en/source-installation.html

而本文接下来的部分为参考官方文档在我的环境里的实践。
——————————————————

系统要求:
cmake:
至少2.8的版本。当前官方cmake的最新版本为3.4.0,你可以从官方网站下载它,并安装。(具体的配置会在下面的章节里陈述)
官方网站 – https://cmake.org/download/
Download = https://cmake.org/files/v3.4/cmake-3.4.0.tar.gz

make(GNU make):
至少3.75的版本。最新版:4.1。
官方网站 – http://www.gnu.org/software/make/
Download = http://ftp.gnu.org/gnu/make/make-4.1.tar.gz

Gcc:
至少4.4.6,最新版:5.2
官方网站 – http://gcc.gnu.org/
Download = https://ftp.gnu.org/gnu/gcc/gcc-5.2.0/gcc-5.2.0.tar.gz

(如果你希望运行测试脚本,你还需要Perl。)

Boost:
官方网站 – http://www.boost.org/
Download =
http://downloads.sourceforge.net/project/boost/boost/1.59.0/boost_1_59_0.tar.gz?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fboost%2Ffiles%2Fboost%2F1.59.0%2F&ts=1448510456&use_mirror=nchc

——————————————————
根据系统要求一步步的做安装前部署:
一、C++编译器:
首先,是C++的编译器(gcc-c++):

[root@rhel6 cmake-3.4.0]# yum install gcc
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package gcc.x86_64 0:4.4.7-4.el6 will be installed
--> Processing Dependency: cpp = 4.4.7-4.el6 for package: gcc-4.4.7-4.el6.x86_64
--> Processing Dependency: cloog-ppl >= 0.15 for package: gcc-4.4.7-4.el6.x86_64
--> Running transaction check
---> Package cloog-ppl.x86_64 0:0.15.7-1.2.el6 will be installed
--> Processing Dependency: libppl_c.so.2()(64bit) for package: cloog-ppl-0.15.7-1.2.el6.x86_64
--> Processing Dependency: libppl.so.7()(64bit) for package: cloog-ppl-0.15.7-1.2.el6.x86_64
---> Package cpp.x86_64 0:4.4.7-4.el6 will be installed
--> Processing Dependency: libmpfr.so.1()(64bit) for package: cpp-4.4.7-4.el6.x86_64
--> Running transaction check
---> Package mpfr.x86_64 0:2.4.1-6.el6 will be installed
---> Package ppl.x86_64 0:0.10.2-11.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=====================================================================================================================================================
 Package                             Arch                             Version                                    Repository                     Size
=====================================================================================================================================================
Installing:
 gcc                                 x86_64                           4.4.7-4.el6                                ISO                            10 M
Installing for dependencies:
 cloog-ppl                           x86_64                           0.15.7-1.2.el6                             ISO                            93 k
 cpp                                 x86_64                           4.4.7-4.el6                                ISO                           3.7 M
 mpfr                                x86_64                           2.4.1-6.el6                                ISO                           156 k
 ppl                                 x86_64                           0.10.2-11.el6                              ISO                           1.3 M

Transaction Summary
=====================================================================================================================================================
Install       5 Package(s)

Total download size: 15 M
Installed size: 33 M
Is this ok [y/N]: y
Downloading Packages:
-----------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                 69 MB/s |  15 MB     00:00     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : mpfr-2.4.1-6.el6.x86_64                                                                                                           1/5 
  Installing : cpp-4.4.7-4.el6.x86_64                                                                                                            2/5 
  Installing : ppl-0.10.2-11.el6.x86_64                                                                                                          3/5 
  Installing : cloog-ppl-0.15.7-1.2.el6.x86_64                                                                                                   4/5 
  Installing : gcc-4.4.7-4.el6.x86_64                                                                                                            5/5 
HighAvailability/productid                                                                                                    | 1.7 kB     00:00 ... 
ISO/productid                                                                                                                 | 1.7 kB     00:00 ... 
LoadBalancer/productid                                                                                                        | 1.7 kB     00:00 ... 
ResilientStorage/productid                                                                                                    | 1.7 kB     00:00 ... 
ScalableFileSystem/productid                                                                                                  | 1.8 kB     00:00 ... 
Server/productid                                                                                                              | 1.7 kB     00:00 ... 
  Verifying  : gcc-4.4.7-4.el6.x86_64                                                                                                            1/5 
  Verifying  : ppl-0.10.2-11.el6.x86_64                                                                                                          2/5 
  Verifying  : cloog-ppl-0.15.7-1.2.el6.x86_64                                                                                                   3/5 
  Verifying  : mpfr-2.4.1-6.el6.x86_64                                                                                                           4/5 
  Verifying  : cpp-4.4.7-4.el6.x86_64                                                                                                            5/5 

Installed:
  gcc.x86_64 0:4.4.7-4.el6                                                                                                                           

Dependency Installed:
  cloog-ppl.x86_64 0:0.15.7-1.2.el6          cpp.x86_64 0:4.4.7-4.el6          mpfr.x86_64 0:2.4.1-6.el6          ppl.x86_64 0:0.10.2-11.el6         

Complete!
[root@rhel6 cmake-3.4.0]# 
[root@rhel6 cmake-3.4.0]# yum list | grep --color gcc-c++
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
gcc-c++.x86_64                      4.4.7-4.el6                 ISO             
[root@rhel6 cmake-3.4.0]# yum install -y gcc-c++
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package gcc-c++.x86_64 0:4.4.7-4.el6 will be installed
--> Processing Dependency: libstdc++-devel = 4.4.7-4.el6 for package: gcc-c++-4.4.7-4.el6.x86_64
--> Running transaction check
---> Package libstdc++-devel.x86_64 0:4.4.7-4.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=====================================================================================================================================================
 Package                                  Arch                            Version                                 Repository                    Size
=====================================================================================================================================================
Installing:
 gcc-c++                                  x86_64                          4.4.7-4.el6                             ISO                          4.7 M
Installing for dependencies:
 libstdc++-devel                          x86_64                          4.4.7-4.el6                             ISO                          1.6 M

Transaction Summary
=====================================================================================================================================================
Install       2 Package(s)

Total download size: 6.3 M
Installed size: 20 M
Downloading Packages:
-----------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                 61 MB/s | 6.3 MB     00:00     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : libstdc++-devel-4.4.7-4.el6.x86_64                                                                                                1/2 
  Installing : gcc-c++-4.4.7-4.el6.x86_64                                                                                                        2/2 
  Verifying  : gcc-c++-4.4.7-4.el6.x86_64                                                                                                        1/2 
  Verifying  : libstdc++-devel-4.4.7-4.el6.x86_64                                                                                                2/2 

Installed:
  gcc-c++.x86_64 0:4.4.7-4.el6                                                                                                                       

Dependency Installed:
  libstdc++-devel.x86_64 0:4.4.7-4.el6                                                                                                               

Complete!
[root@rhel6 cmake-3.4.0]# 

二、安装ncurses-devel。

[root@rhel6 boost]# yum list | grep --color ncurses-devel
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
ncurses-devel.i686                  5.7-3.20090208.el6          ISO             
ncurses-devel.x86_64                5.7-3.20090208.el6          ISO             
[root@rhel6 boost]# yum install ncurses-devel
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package ncurses-devel.x86_64 0:5.7-3.20090208.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=====================================================================================================================================================
 Package                               Arch                           Version                                      Repository                   Size
=====================================================================================================================================================
Installing:
 ncurses-devel                         x86_64                         5.7-3.20090208.el6                           ISO                         642 k

Transaction Summary
=====================================================================================================================================================
Install       1 Package(s)

Total download size: 642 k
Installed size: 1.7 M
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : ncurses-devel-5.7-3.20090208.el6.x86_64                                                                                           1/1 
  Verifying  : ncurses-devel-5.7-3.20090208.el6.x86_64                                                                                           1/1 

Installed:
  ncurses-devel.x86_64 0:5.7-3.20090208.el6                                                                                                          

Complete!
[root@rhel6 boost]#

如果缺少ncurses-devel,那么在生成MySQL编译配置文件的时候如果指定了“-DWITH_READLINE=ON”,则会遇到如下错误:

-- Check size of wchar_t - done
-- Check size of wint_t
-- Check size of wint_t - done
-- Could NOT find Curses (missing:  CURSES_LIBRARY CURSES_INCLUDE_PATH) 
CMake Error at cmake/readline.cmake:64 (MESSAGE):
  Curses library not found.  Please install appropriate package,

      remove CMakeCache.txt and rerun cmake.On Debian/Ubuntu, package name is libncurses5-dev, on Redhat and derivates it is ncurses-devel.
Call Stack (most recent call first):
  cmake/readline.cmake:107 (FIND_CURSES)
  cmake/readline.cmake:181 (MYSQL_USE_BUNDLED_EDITLINE)
  CMakeLists.txt:463 (MYSQL_CHECK_EDITLINE)


-- Configuring incomplete, errors occurred!
See also "/software/mysql-5.7.9/CMakeFiles/CMakeOutput.log".
See also "/software/mysql-5.7.9/CMakeFiles/CMakeError.log".
[root@rhel6 mysql-5.7.9]# 

三、
cmake的源码包安装:http://d-prototype.com/archives/3784
查看cmake的版本:

[root@rhel6 cmake-3.4.0]# cmake -version
cmake version 3.4.0

CMake suite maintained and supported by Kitware (kitware.com/cmake).
[root@rhel6 cmake-3.4.0]# 

四、
make的源码包安装:http://d-prototype.com/archives/3786
五、
Boost类库的安装与测试:http://d-prototype.com/archives/3788
——————————————————
MySQL的安装。

解压安装包:

[root@rhel6 software]# pwd
/software
[root@rhel6 software]# 
[root@rhel6 software]# ls -ltr | grep mysql
-rw-r--r--  1 root root  63895259 Nov 21 09:59 mysql-5.7.9.zip
[root@rhel6 software]# 
[root@rhel6 software]# du -sh mysql*
61M     mysql-5.7.9.zip
[root@rhel6 software]# 
[root@rhel6 software]# unzip mysql-5.7.9.zip 
(... ... 过多的输出。)
  inflating: mysql-5.7.9/mysql-test/lib/My/Test.pm  
  inflating: mysql-5.7.9/mysql-test/lib/My/Platform.pm  
   creating: mysql-5.7.9/mysql-test/lib/My/SafeProcess/
  inflating: mysql-5.7.9/mysql-test/lib/My/SafeProcess/CMakeLists.txt  
  inflating: mysql-5.7.9/mysql-test/lib/My/SafeProcess/safe_process.cc  
  inflating: mysql-5.7.9/mysql-test/lib/My/SafeProcess/safe_process_win.cc  
  inflating: mysql-5.7.9/mysql-test/lib/My/SafeProcess/safe_kill_win.cc  
  inflating: mysql-5.7.9/mysql-test/lib/My/SafeProcess/Base.pm  
  inflating: mysql-5.7.9/mysql-test/lib/My/Memcache.pm  
  inflating: mysql-5.7.9/mysql-test/lib/My/Handles.pm  
  inflating: mysql-5.7.9/mysql-test/lib/My/Config.pm  
  inflating: mysql-5.7.9/mysql-test/lib/My/CoreDump.pm  
  inflating: mysql-5.7.9/mysql-test/lib/mtr_io.pl  
  inflating: mysql-5.7.9/mysql-test/lib/mtr_misc.pl  
  inflating: mysql-5.7.9/mysql-test/lib/mtr_gcov.pl  
[root@rhel6 software]# 
[root@rhel6 software]# ls -l | grep --color mysql
drwxr-xr-x 34 root root      4096 Oct 12 14:21 mysql-5.7.9
-rw-r--r--  1 root root  63895259 Nov 21 09:59 mysql-5.7.9.zip
[root@rhel6 software]# cd mysql-5.7.9
[root@rhel6 mysql-5.7.9]# ls
BUILD           cmd-line-utils   Docs                 INSTALL-WIN-SOURCE   libmysqld    mysys_ssl  scripts     support-files  win
BUILD-CMAKE     config.h.cmake   Doxyfile-perfschema  libbinlogevents      libservices  packaging  sql         testclients    zlib
client          configure.cmake  extra                libbinlogstandalone  man          plugin     sql-common  unittest
cmake           COPYING          include              libevent             mysql-test   README     storage     VERSION
CMakeLists.txt  dbug             INSTALL-SOURCE       libmysql             mysys        regex      strings     vio
[root@rhel6 mysql-5.7.9]# 

规划:
MySQL的软件目录:/usr/local/mysql
数据目录:/data/db/mysql-data
配置文件目录:/data/db/mysql/confdir/

创建目录:

[root@rhel6 mysql-5.7.9]# mkdir /usr/local/mysql
[root@rhel6 mysql-5.7.9]# mkdir -p /data/db/mysql/confdir/
[root@rhel6 mysql-5.7.9]# mkdir -p /data/db/mysql-data

生成编译配置文件:
命令:
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/db/mysql-data -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DENABLED_LOCAL_INFILE=ON -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_FEDERATED_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DWITH_PERFSCHEMA_STORAGE_ENGINE=1 -DCOMPILATION_COMMENT=’Adamhuan DB’ -DWITH_READLINE=ON -DSYSCONFDIR=/data/db/mysql/confdir -DMYSQL_UNIX_ADDR=/data/db/mysql/confdir/mysql.sock

[root@rhel6 mysql-5.7.9]# cmake . \
> -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
> -DMYSQL_DATADIR=/data/db/mysql-data \
> -DDEFAULT_CHARSET=utf8 \
> -DDEFAULT_COLLATION=utf8_general_ci \
> -DENABLED_LOCAL_INFILE=ON \
> -DWITH_INNOBASE_STORAGE_ENGINE=1 \
> -DWITH_FEDERATED_STORAGE_ENGINE=1 \
> -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
> -DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 \
> -DWITH_PARTITION_STORAGE_ENGINE=1 \
> -DWITH_PERFSCHEMA_STORAGE_ENGINE=1 \
> -DCOMPILATION_COMMENT='Adamhuan DB' \
> -DWITH_READLINE=ON \
> -DSYSCONFDIR=/data/db/mysql/confdir \
> -DMYSQL_UNIX_ADDR=/data/db/mysql/confdir/mysql.sock

-- Running cmake version 3.4.0
-- Could NOT find Git (missing:  GIT_EXECUTABLE) 
-- Configuring with MAX_INDEXES = 64U
-- SIZEOF_VOIDP 8
-- MySQL 5.7.9
-- Packaging as: mysql-5.7.9-Linux-x86_64
-- Local boost dir /usr/local/boost_1_59_0
-- Found /usr/local/boost_1_59_0/boost/version.hpp 
-- BOOST_VERSION_NUMBER is #define BOOST_VERSION 105900
-- BOOST_INCLUDE_DIR /usr/local/boost_1_59_0
-- Found Curses: /usr/lib64/libcurses.so  
-- Looking for tputs in /usr/lib64/libcurses.so
-- Looking for tputs in /usr/lib64/libcurses.so - found
-- Performing Test HAVE_DECL_TGOTO
-- Performing Test HAVE_DECL_TGOTO - Success
-- Looking for strvis
-- Looking for strvis - not found
-- Looking for strunvis
-- Looking for strunvis - not found
-- Performing Test HAVE_SYS_THREAD_SELFID
-- Performing Test HAVE_SYS_THREAD_SELFID - Failed
-- Performing Test HAVE_SYS_GETTID
-- Performing Test HAVE_SYS_GETTID - Success
-- Performing Test HAVE_PTHREAD_GETTHREADID_NP
-- Performing Test HAVE_PTHREAD_GETTHREADID_NP - Failed
-- Performing Test HAVE_INTEGER_PTHREAD_SELF
-- Performing Test HAVE_INTEGER_PTHREAD_SELF - Success
-- Looking for include file libaio.h
-- Looking for include file libaio.h - not found
-- Looking for io_queue_init in aio
-- Looking for io_queue_init in aio - not found
-- Performing Test HAVE_NO_BUILTIN_MEMCMP
-- Performing Test HAVE_NO_BUILTIN_MEMCMP - Success
-- Looking for sched_getcpu
-- Looking for sched_getcpu - found
-- Looking for nanosleep
-- Looking for nanosleep - found
-- Performing Test HAVE_FALLOC_PUNCH_HOLE_AND_KEEP_SIZE
-- Performing Test HAVE_FALLOC_PUNCH_HOLE_AND_KEEP_SIZE - Success
-- Performing Test HAVE_IB_GCC_SYNC_SYNCHRONISE
-- Performing Test HAVE_IB_GCC_SYNC_SYNCHRONISE - Success
-- Performing Test HAVE_IB_GCC_ATOMIC_THREAD_FENCE
-- Performing Test HAVE_IB_GCC_ATOMIC_THREAD_FENCE - Failed
-- Performing Test HAVE_IB_GCC_ATOMIC_COMPARE_EXCHANGE
-- Performing Test HAVE_IB_GCC_ATOMIC_COMPARE_EXCHANGE - Failed
-- Performing Test HAVE_IB_ATOMIC_PTHREAD_T_GCC
-- Performing Test HAVE_IB_ATOMIC_PTHREAD_T_GCC - Success
-- Performing Test HAVE_IB_LINUX_FUTEX
-- Performing Test HAVE_IB_LINUX_FUTEX - Success
-- Looking for asprintf
-- Looking for asprintf - found
-- Using cmake version 3.4.0
-- Performing Test HAVE_UNUSED_BUT_SET_VARIABLE
-- Performing Test HAVE_UNUSED_BUT_SET_VARIABLE - Success
-- Disabling -Wunused-but-set-variable warning for building NDB
-- Performing Test HAVE_STRICT_ALIASING
-- Performing Test HAVE_STRICT_ALIASING - Success
-- Disabling -Wstrict-aliasing warning for building NDB
-- Not building NDB
-- Performing Test HAVE_PEERCRED
-- Performing Test HAVE_PEERCRED - Success
-- Performing Test HAVE_NO_DEPREC_CONST
-- Performing Test HAVE_NO_DEPREC_CONST - Success
-- Library mysqlclient depends on OSLIBS -lpthread;m;rt;dl
-- Looking for include file endian.h
-- Looking for include file endian.h - found
-- Looking for le64toh
-- Looking for le64toh - found
-- Looking for le32toh
-- Looking for le32toh - found
-- Looking for le16toh
-- Looking for le16toh - found
-- Check size of long long
-- Check size of long long - done
-- Check size of long
-- Check size of long - done
-- Check size of int
-- Check size of int - done
-- Check if the system is big endian
-- Searching 16 bit integer
-- Using unsigned short
-- Check if the system is big endian - little endian
-- Found ZLIB: zlib (found version "1.2.3") 
-- Googlemock was not found. gtest-based unit tests will be disabled. You can run cmake . -DENABLE_DOWNLOADS=1 to automatically download and build required components from source.
-- If you are inside a firewall, you may need to use an http proxy: export http_proxy=http://example.com:80
-- Performing Test HAVE_NO_UNUSED_TYPEDEFS
-- Performing Test HAVE_NO_UNUSED_TYPEDEFS - Success
-- Performing Test HAVE_NO_LOGICAL_OP
-- Performing Test HAVE_NO_LOGICAL_OP - Success
CMake Warning at cmake/bison.cmake:20 (MESSAGE):
  Bison executable not found in PATH
Call Stack (most recent call first):
  sql/CMakeLists.txt:502 (INCLUDE)


CMake Warning at cmake/bison.cmake:20 (MESSAGE):
  Bison executable not found in PATH
Call Stack (most recent call first):
  libmysqld/CMakeLists.txt:133 (INCLUDE)


-- Library mysqlserver depends on OSLIBS -lpthread;m;rt;crypt;dl
-- INSTALL mysqlclient.pc lib/pkgconfig
-- CMAKE_BUILD_TYPE: RelWithDebInfo
-- COMPILE_DEFINITIONS: _GNU_SOURCE;_FILE_OFFSET_BITS=64;HAVE_CONFIG_H
-- CMAKE_C_FLAGS:  -Wall -Wextra -Wformat-security -Wvla -Wwrite-strings -Wdeclaration-after-statement
-- CMAKE_CXX_FLAGS:  -Wall -Wextra -Wformat-security -Wvla -Woverloaded-virtual -Wno-unused-parameter
-- CMAKE_C_FLAGS_RELWITHDEBINFO: -O3 -g -fabi-version=2 -fno-omit-frame-pointer -fno-strict-aliasing -DDBUG_OFF
-- CMAKE_CXX_FLAGS_RELWITHDEBINFO: -O3 -g -fabi-version=2 -fno-omit-frame-pointer -fno-strict-aliasing -DDBUG_OFF
-- Configuring done
-- Generating done
-- Build files have been written to: /software/mysql-5.7.9
[root@rhel6 mysql-5.7.9]# 

然后就可以执行编译以及安装了。

编译:make

[root@rhel6 mysql-5.7.9]# make
(... ... 过多的输出。)

[ 98%] Building CXX object libmysqld/CMakeFiles/sql_embedded.dir/__/sql/trigger_chain.cc.o
[ 98%] Building CXX object libmysqld/CMakeFiles/sql_embedded.dir/__/sql/tztime.cc.o
[ 98%] Building CXX object libmysqld/CMakeFiles/sql_embedded.dir/__/sql/uniques.cc.o
[ 98%] Building CXX object libmysqld/CMakeFiles/sql_embedded.dir/__/sql/unireg.cc.o
[100%] Building CXX object libmysqld/CMakeFiles/sql_embedded.dir/__/sql/xa.cc.o
[100%] Linking CXX static library libsql_embedded.a
[100%] Built target sql_embedded
[100%] Generating mysqlserver_depends.c
Scanning dependencies of target mysqlserver
[100%] Building C object libmysqld/CMakeFiles/mysqlserver.dir/mysqlserver_depends.c.o
[100%] Linking C static library libmysqld.a
/usr/bin/ar: creating /software/mysql-5.7.9/libmysqld/libmysqld.a
[100%] Built target mysqlserver
Scanning dependencies of target mysql_client_test_embedded
[100%] Building C object libmysqld/examples/CMakeFiles/mysql_client_test_embedded.dir/__/__/testclients/mysql_client_test.c.o
[100%] Linking CXX executable mysql_client_test_embedded
[100%] Built target mysql_client_test_embedded
Scanning dependencies of target mysql_embedded
[100%] Building CXX object libmysqld/examples/CMakeFiles/mysql_embedded.dir/__/__/client/completion_hash.cc.o
[100%] Building CXX object libmysqld/examples/CMakeFiles/mysql_embedded.dir/__/__/client/mysql.cc.o
[100%] Building CXX object libmysqld/examples/CMakeFiles/mysql_embedded.dir/__/__/client/readline.cc.o
[100%] Linking CXX executable mysql_embedded
[100%] Built target mysql_embedded
Scanning dependencies of target mysqltest_embedded
[100%] Building CXX object libmysqld/examples/CMakeFiles/mysqltest_embedded.dir/__/__/client/mysqltest.cc.o
[100%] Linking CXX executable mysqltest_embedded
[100%] Built target mysqltest_embedded
Scanning dependencies of target my_safe_process
[100%] Building CXX object mysql-test/lib/My/SafeProcess/CMakeFiles/my_safe_process.dir/safe_process.cc.o
[100%] Linking CXX executable my_safe_process
[100%] Built target my_safe_process
[root@rhel6 mysql-5.7.9]# 

安装前:

[root@rhel6 mysql-5.7.9]# ls /usr/local/mysql/
[root@rhel6 mysql-5.7.9]#

安装:make install

[root@rhel6 mysql-5.7.9]# make install
(... ... 过多的输出。)

-- Installing: /usr/local/mysql/mysql-test/./std_data/parts/t1TIMESTAMP.frm
-- Installing: /usr/local/mysql/mysql-test/./std_data/server-key.pem
-- Installing: /usr/local/mysql/mysql-test/./std_data/bug49823.frm
-- Installing: /usr/local/mysql/mysql-test/./std_data/bug40482-bin.000001
-- Installing: /usr/local/mysql/mysql-test/./std_data/loadxml.dat
-- Installing: /usr/local/mysql/mysql-test/./std_data/bug36055.frm
-- Installing: /usr/local/mysql/mysql-test/./std_data/cluster_7022_table.frm
-- Installing: /usr/local/mysql/mysql-test/./std_data/untrusted-cacert.pem
-- Installing: /usr/local/mysql/mysql-test/./std_data/bug48633.ARM
-- Installing: /usr/local/mysql/mysql-test/./std_data/55_temporal.MYI
-- Installing: /usr/local/mysql/mysql-test/./std_data/wl6219_55.MYI
-- Installing: /usr/local/mysql/mysql-test/./std_data/bug47012.ARZ
-- Installing: /usr/local/mysql/mysql-test/./std_data/bug19371.frm
-- Installing: /usr/local/mysql/mysql-test/./std_data/rpl_timezone.dat
-- Installing: /usr/local/mysql/mysql-test/./README.gcov
-- Up-to-date: /usr/local/mysql/mysql-test/mtr
-- Up-to-date: /usr/local/mysql/mysql-test/mysql-test-run
-- Installing: /usr/local/mysql/mysql-test/lib/My/SafeProcess/my_safe_process
-- Up-to-date: /usr/local/mysql/mysql-test/lib/My/SafeProcess/my_safe_process
-- Installing: /usr/local/mysql/mysql-test/lib/My/SafeProcess/Base.pm
-- Installing: /usr/local/mysql/support-files/my-default.cnf
-- Installing: /usr/local/mysql/support-files/mysqld_multi.server
-- Installing: /usr/local/mysql/support-files/mysql-log-rotate
-- Installing: /usr/local/mysql/support-files/magic
-- Installing: /usr/local/mysql/share/aclocal/mysql.m4
-- Installing: /usr/local/mysql/support-files/mysql.server
[root@rhel6 mysql-5.7.9]# 

安装后:

[root@rhel6 mysql-5.7.9]# ls /usr/local/mysql/
bin  COPYING  docs  include  INSTALL-BINARY  lib  man  mysql-test  README  share  support-files
[root@rhel6 mysql-5.7.9]# 

这样,MySQL就安装好了。

启动MySQL。

创建配置文件:
官方的文档提供了一些配置文件的样例:

[mysql@rhel6 mysql]$ pwd
/usr/local/mysql
[mysql@rhel6 mysql]$ ls
bin  COPYING  docs  include  INSTALL-BINARY  lib  man  mysql-test  README  share  support-files
[mysql@rhel6 mysql]$ 
[mysql@rhel6 mysql]$ ls support-files/
magic  my-default.cnf  mysqld_multi.server  mysql-log-rotate  mysql.server
[mysql@rhel6 mysql]$ 
[mysql@rhel6 mysql]$ cat support-files/my-default.cnf 
# 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 = .....

# 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 
[mysql@rhel6 mysql]$ 

将配置文件模板复制到配置文件路径(/data/db/mysql/confdir/),然后做出适当的修改:

[root@rhel6 confdir]# cp /usr/local/mysql/support-files/my-default.cnf my.cnf
[root@rhel6 confdir]# 
[root@rhel6 confdir]# ls
my.cnf  my.cnf_backup_20151126_1827_adamhuan
[root@rhel6 confdir]# cat my.cnf
# 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.

[client]
port = 3306
socket = /data/db/mysql/confdir/mysql.sock

[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 = .....

basedir = /usr/local/mysql
datadir = /data/db/mysql-data
port = 3306
socket = /data/db/mysql/confdir/mysql.sock


# 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 

join_buffer_size = 4m
sort_buffer_size = 2m

read_rnd_buffer_size = 16m
read_buffer_size = 2m

max_allowed_packet = 256m
max_heap_table_size = 256m

net_buffer_length = 8k

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES 
[root@rhel6 confdir]# 

创建需要的目录结构:

[root@rhel6 boost]# mkdir /data/db/mysql/tmp
[root@rhel6 boost]# mkdir /data/db/mysql/binlog
[root@rhel6 boost]# 

创建用户:mysql

[root@rhel6 boost]# useradd mysql
[root@rhel6 boost]# passwd mysql
Changing password for user mysql.
New password: 
BAD PASSWORD: it is based on a dictionary word
BAD PASSWORD: is too simple
Retype new password: 
passwd: all authentication tokens updated successfully.
[root@rhel6 boost]# 
[root@rhel6 boost]# id mysql
uid=500(mysql) gid=500(mysql) groups=500(mysql)
[root@rhel6 boost]# 

修改:limits.conf

[root@rhel6 ~]# cat /etc/security/limits.conf 
# /etc/security/limits.conf
#
#Each line describes a limit for a user in the form:
#
#<domain>        <type>  <item>  <value>
#
#Where:
#<domain> can be:
#        - an user name
#        - a group name, with @group syntax
#        - the wildcard *, for default entry
#        - the wildcard %, can be also used with %group syntax,
#                 for maxlogin limit
#
#<type> can have the two values:
#        - "soft" for enforcing the soft limits
#        - "hard" for enforcing hard limits
#
#<item> can be one of the following:
#        - core - limits the core file size (KB)
#        - data - max data size (KB)
#        - fsize - maximum filesize (KB)
#        - memlock - max locked-in-memory address space (KB)
#        - nofile - max number of open files
#        - rss - max resident set size (KB)
#        - stack - max stack size (KB)
#        - cpu - max CPU time (MIN)
#        - nproc - max number of processes
#        - as - address space limit (KB)
#        - maxlogins - max number of logins for this user
#        - maxsyslogins - max number of logins on the system
#        - priority - the priority to run user process with
#        - locks - max number of file locks the user can hold
#        - sigpending - max number of pending signals
#        - msgqueue - max memory used by POSIX message queues (bytes)
#        - nice - max nice priority allowed to raise to values: [-20, 19]
#        - rtprio - max realtime priority
#
#<domain>      <type>  <item>         <value>
#

#*               soft    core            0
#*               hard    rss             10000
#@student        hard    nproc           20
#@faculty        soft    nproc           20
#@faculty        hard    nproc           50
#ftp             hard    nproc           0
#@student        -       maxlogins       4

# End of file

# MySQL
mysql   soft    nproc   2047
mysql   hard    nproc   16384

mysql   soft    nofile  1024
mysql   hard    nofile  65536
[root@rhel6 ~]# 

赋予权限:

[root@rhel6 boost]# ll -d /usr/local/mysql
drwxr-xr-x 10 root root 4096 Nov 24 14:21 /usr/local/mysql
[root@rhel6 boost]# 
[root@rhel6 boost]# chown -R mysql.mysql /usr/local/mysql/
[root@rhel6 boost]# 
[root@rhel6 ~]# ll /data/db/
total 8
drwxr-xr-x 5 root root 4096 Nov 24 14:42 mysql
drwxr-xr-x 2 root root 4096 Nov 24 14:55 mysql-data
[root@rhel6 ~]# chown -R mysql.mysql /data/
[root@rhel6 ~]# ll /data/db/
total 8
drwxr-xr-x 5 mysql mysql 4096 Nov 24 14:42 mysql
drwxr-xr-x 2 mysql mysql 4096 Nov 24 14:55 mysql-data
[root@rhel6 ~]# 

初始化MySQL数据库:
初始化之前:

[root@rhel6 ~]# export LANG=en_US
[root@rhel6 ~]# tree /data
/data
`-- db
    |-- mysql
    |   |-- binlog
    |   |-- confdir
    |   |   `-- my.cnf
    |   `-- tmp
    `-- mysql-data

6 directories, 1 file
[root@rhel6 ~]# du -sh /data
32K     /data
[root@rhel6 ~]# 

开始初始化:

初始化数据目录的方法有两种。
在5.7.6之前的MySQL中,使用“mysql_install_db”,例:
bin/mysql_install_db –datadir=/data/db/mysql-data/ –basedir=/usr/local/mysql

而对于5.7.6,通过“mysqld”的“–initialize”选项操作,具体如下:

[root@rhel6 boost]# su - mysql
[mysql@rhel6 ~]$ cd /usr/local/mysql/
[mysql@rhel6 mysql]$ ls
bin  COPYING  docs  include  INSTALL-BINARY  lib  man  mysql-test  README  share  support-files
[mysql@rhel6 mysql]$ 
[mysql@rhel6 mysql]$ ls bin | grep --color mysqld
mysqld
mysqld_multi
mysqld_safe
mysqldump
mysqldumpslow
[mysql@rhel6 mysql]$ 
[root@rhel6 mysql-data]# /usr/local/mysql/bin/mysqld --initialize --user=mysql
2015-11-24T08:37:14.099333Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2015-11-24T08:37:14.099390Z 0 [Warning] 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release.
2015-11-24T08:37:14.099394Z 0 [Warning] 'NO_AUTO_CREATE_USER' sql mode was not set.
2015-11-24T08:37:14.602529Z 0 [Warning] InnoDB: New log files created, LSN=45790
2015-11-24T08:37:14.725770Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2015-11-24T08:37:14.796151Z 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: 903e92ea-9286-11e5-9f43-000c29b78a1d.
2015-11-24T08:37:14.797477Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2015-11-24T08:37:14.802308Z 1 [Note] A temporary password is generated for root@localhost: 3Aq*<;XRl,ot
[root@rhel6 mysql-data]# 

注意,最后一段话:“A temporary password is generated for ...”,这是初始化时随机生成的口令,在登陆MySQL的时候使用。

初始化之后:

[root@rhel6 ~]# ls /data/db/mysql-data/
auto.cnf  ib_buffer_pool  ibdata1  ib_logfile0  ib_logfile1  mysql  performance_schema  sys
[root@rhel6 ~]# 
[root@rhel6 ~]# du -sh /data/
122M    /data/
[root@rhel6 ~]# 
[root@rhel6 ~]# du -sh /data/db/mysql-data/*
4.0K    /data/db/mysql-data/auto.cnf
4.0K    /data/db/mysql-data/ib_buffer_pool
12M     /data/db/mysql-data/ibdata1
48M     /data/db/mysql-data/ib_logfile0
48M     /data/db/mysql-data/ib_logfile1
12M     /data/db/mysql-data/mysql
1.1M    /data/db/mysql-data/performance_schema
676K    /data/db/mysql-data/sys
[root@rhel6 ~]# 

打开数据库:
启动MySQL数据库服务:

[root@rhel6 boost]# cd /usr/local/mysql/
[root@rhel6 mysql]#
[root@rhel6 mysql]# bin/mysqld --user=mysql
2015-11-24T07:37:20.541417Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2015-11-24T07:37:20.541479Z 0 [Warning] 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release.
2015-11-24T07:37:20.541483Z 0 [Warning] 'NO_AUTO_CREATE_USER' sql mode was not set.
2015-11-24T07:37:20.541509Z 0 [Warning] Insecure configuration for --secure-file-priv: Current value does not restrict location of generated files. Consider setting it to a valid, non-empty path.
2015-11-24T07:37:20.541539Z 0 [Note] bin/mysqld (mysqld 5.7.9) starting as process 55876 ...
2015-11-24T07:37:20.545720Z 0 [Note] InnoDB: PUNCH HOLE support available
2015-11-24T07:37:20.545772Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2015-11-24T07:37:20.545778Z 0 [Note] InnoDB: Uses event mutexes
2015-11-24T07:37:20.545782Z 0 [Note] InnoDB: GCC builtin __sync_synchronize() is used for memory barrier
2015-11-24T07:37:20.545785Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.3
2015-11-24T07:37:20.546062Z 0 [Note] InnoDB: Number of pools: 1
2015-11-24T07:37:20.546162Z 0 [Note] InnoDB: Using CPU crc32 instructions
2015-11-24T07:37:20.553110Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2015-11-24T07:37:20.567295Z 0 [Note] InnoDB: Completed initialization of buffer pool
2015-11-24T07:37:20.570094Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2015-11-24T07:37:20.583724Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
2015-11-24T07:37:20.599633Z 0 [Note] InnoDB: Removed temporary tablespace data file: "ibtmp1"
2015-11-24T07:37:20.599657Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2015-11-24T07:37:20.599711Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2015-11-24T07:37:20.629508Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2015-11-24T07:37:20.630615Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
2015-11-24T07:37:20.630632Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
2015-11-24T07:37:20.631442Z 0 [Note] InnoDB: Waiting for purge to start
2015-11-24T07:37:20.681961Z 0 [Note] InnoDB: 5.7.9 started; log sequence number 2471242
2015-11-24T07:37:20.682592Z 0 [Note] Plugin 'FEDERATED' is disabled.
2015-11-24T07:37:20.684374Z 0 [Warning] Failed to set up SSL because of the following SSL library error: SSL context is not usable without certificate and private key
2015-11-24T07:37:20.684396Z 0 [Note] Server hostname (bind-address): '*'; port: 3306
2015-11-24T07:37:20.684468Z 0 [Note] IPv6 is available.
2015-11-24T07:37:20.684496Z 0 [Note]   - '::' resolves to '::';
2015-11-24T07:37:20.684504Z 0 [Note] Server socket created on IP: '::'.
2015-11-24T07:37:20.685033Z 0 [Note] InnoDB: not started
2015-11-24T07:37:20.685259Z 0 [Note] InnoDB: Loading buffer pool(s) from /data/db/mysql-data/ib_buffer_pool
2015-11-24T07:37:20.687285Z 0 [Note] InnoDB: Buffer pool(s) load completed at 151124 15:37:20
2015-11-24T07:37:20.704418Z 0 [Note] Event Scheduler: Loaded 0 events
2015-11-24T07:37:20.704531Z 0 [Note] bin/mysqld: ready for connections.
Version: '5.7.9'  socket: '/data/db/mysql/confdir/mysql.sock'  port: 3306  Adamhuan DB

(Blocking,...)

然后,在另一个会话中查看:

[root@rhel6 bin]# ps -ef | grep --color mysql
root      57847  41065  0 16:28 pts/3    00:00:00 tail -f /var/log/mysqld.log
mysql     59132  40890  2 16:40 pts/1    00:00:00 /usr/local/mysql/bin/mysqld --user=mysql
root      59161  55951  0 16:40 pts/5    00:00:00 grep --color mysql
[root@rhel6 bin]# 
[root@rhel6 bin]# /usr/local/mysql/bin/mysql -uroot -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.

Segmentation fault (core dumped)
[root@rhel6 bin]# 

正常的情况下,这里应该是可以正常登入MySQL的客户端了,但这里却报错“Segmentation fault (core dumped)”,还在解决中。
————————————————
To be Continue。

2
说点什么

avatar
2 Comment threads
0 Thread replies
0 Followers
 
Most reacted comment
Hottest comment thread
2 Comment authors
Adamhuan腹黑的艾利 Recent comment authors

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据

  Subscribe  
提醒