Linux中Mysql源码安装---编译安装

1、下载解压Mysql
[root@node1 ~]# wget http://cdn.mysql.com//Downloads/MySQL-5.6/mysql-5.6.28.tar.gz
--13:12:16--  http://cdn.mysql.com//Downloads/MySQL-5.6/mysql-5.6.28.tar.gz
[root@node1 ~]# tar -zxvf mysql-5.6.28.tar.gz

2、安装cmake
[root@node1 ~]# tar -zxvf cmake-2.8.10.2.tar.gz
[root@node1 ~]# cd cmake-2.8.10.2
[root@node1 cmake-2.8.10.2]# ./configure
-- Performing Test run_pic_test - Success
-- Configuring done
-- Generating done
-- Build files have been written to: /root/cmake-2.8.10.2
---------------------------------------------
CMake has bootstrapped.  Now run gmake.
[root@node1 cmake-2.8.10.2]# make
Scanning dependencies of target pseudo_valgrind
[100%] Building C object Tests/CTestTestMemcheck/CMakeFiles/pseudo_valgrind.dir/ret0.c.o
Linking C executable valgrind
[100%] Built target pseudo_valgrind
[root@node1 cmake-2.8.10.2]# make install
-- Installing: /usr/local/bin/cmake
-- Installing: /usr/local/bin/cpack
-- Installing: /usr/local/bin/ctest
-- Installing: /usr/local/man/man1/cmake.1
-- Installing: /usr/local/man/man1/cmakecommands.1
[root@node1 cmake-2.8.10.2]# cmake
cmake version 2.8.10.2
Usage

  cmake [options] <path-to-source>
  cmake [options] <path-to-existing-build>

Options
  -C <initial-cache>          = Pre-load a script to populate the cache.
  -D <var>:<type>=<value>     = Create a cmake cache entry.
  -U <globbing_expr>          = Remove matching entries from CMake cache.
  -G <generator-name>         = Specify a makefile generator.
  -Wno-dev                    = Suppress developer warnings.
  -Wdev                       = Enable developer warnings.
  -E                          = CMake command mode.
  -i                          = Run in wizard mode.
  -L[A][H]                    = List non-advanced cached variables.
  --build <dir>               = Build a CMake-generated project binary tree.
  -N                          = View mode only.


 3、安装mysql
[root@node1 mysql-5.6.28]# cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql
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 libncurses5-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:414 (MYSQL_CHECK_EDITLINE)
-- Configuring incomplete, errors occurred!
--【cmake出错解决方案:】
[root@node1 mysql-5.6.28]# rm -rf CMakeCache.txt
[root@node1 mysql-5.6.28]# yum -y install ncurses-devel*
Total download size: 3.3 M
Downloading Packages:
(1/2): ncurses-devel-5.5-24.20060715.i386.rpm                                                                                                                           | 1.6 MB     00:03    
(2/2): ncurses-devel-5.5-24.20060715.x86_64.rpm                                                                                                                         | 1.7 MB     00:04    
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                          398 kB/s | 3.3 MB     00:08    
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing     : ncurses-devel                                     [1/2]
  Installing     : ncurses-devel                                     [2/2]

Installed: ncurses-devel.x86_64 0:5.5-24.20060715 ncurses-devel.i386 0:5.5-24.20060715
Complete!
4、重新安装mysql
[root@node1 mysql-5.6.28]# cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql
-- CMAKE_C_FLAGS:  -Wall -Wextra -Wformat-security -Wwrite-strings -Wdeclaration-after-statement
-- CMAKE_CXX_FLAGS:  -Wall -Wextra -Wformat-security -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: /root/mysql-5.6.28
[root@node1 mysql-5.6.28]# make
[100%] Building CXX object libmysqld/examples/CMakeFiles/mysqltest_embedded.dir/__/__/client/mysqltest.cc.o
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
Linking CXX executable my_safe_process
[100%] Built target my_safe_process
[root@node1 mysql-5.6.28]# make install
编译时候尽量分配多点内存,加块安装速度
-- Installing: /usr/local/mysql/sql-bench/innotest2a
-- Installing: /usr/local/mysql/sql-bench/innotest2
-- Installing: /usr/local/mysql/sql-bench/test-insert
-- Installing: /usr/local/mysql/sql-bench/innotest1b
-- Installing: /usr/local/mysql/sql-bench/test-alter-table
-- Installing: /usr/local/mysql/sql-bench/run-all-tests
-- Installing: /usr/local/mysql/sql-bench/test-transactions
-- Installing: /usr/local/mysql/sql-bench/README
-- Installing: /usr/local/mysql/sql-bench/bench-count-distinct
-- Installing: /usr/local/mysql/sql-bench/graph-compare-results
-- Installing: /usr/local/mysql/sql-bench/bench-init.pl
-- Installing: /usr/local/mysql/sql-bench/compare-results
-- Installing: /usr/local/mysql/sql-bench/server-cfg
-- Installing: /usr/local/mysql/sql-bench/copy-db
-- Installing: /usr/local/mysql/sql-bench/test-ATIS
-- Installing: /usr/local/mysql/sql-bench/test-big-tables
-- Installing: /usr/local/mysql/sql-bench/test-wisconsin
[root@node1 mysql-5.6.28]#
至此Linux源码安装Mysql完毕。

猜你喜欢

转载自gaojingsong.iteye.com/blog/2269330