MySQL為開源數據庫,因此可以基於源碼實現安裝。基於源碼安裝有更多的靈活性。也就是說我們可以針對自己的硬件平台選用合適的編譯器來優化編譯後的二進制代碼,根據不同的軟件平台環境調整相關的編譯參數,選擇自身需要選擇不同的安裝組件,設定需要的字符集等等一些可以根據特定應用場景所作的各種調整。本文描述了如何在源碼方式下安裝MySQL。
1、安裝環境及介質
#安裝介質,可以到以下網址下載安裝介質,注意下載時選擇source code,當前版本為5.6.17
#源碼安裝方式官方網站鏈接: http://dev.mysql.com/doc/refman/5.6/en/installing-source-distribution.html
2、系統需求
Installation of MySQL from source requires several development tools. Some of these tools are needed no matter whether you use a standard source distribution or a development source tree. Other tool requirements depend on which installation method you use.
To install MySQL from source, your system must have the following tools, regardless of installation method:
CMake, which is used as the build framework on all platforms. CMake can be downloaded from http://www.cmake.org.A good make program. Although some platforms come with their own make implementations, it is highly recommended that you use GNU make 3.75 or newer. It may already be available on your system as gmake. GNU make is available from http://www.gnu.org/software/make/.A working ANSI C++ compiler. GCC 4.2.1 or later, Sun Studio 12 or later, Visual Studio 2010 or later, and many current vendor-supplied compilers are known to work.Perl is needed if you intend to run test scripts. Most Unix-like systems include Perl. On Windows, you can use a version such as ActiveState Perl.#使用源碼安裝上面的一些開發工具是需要的,比較重要的一個是Cmake工具,通常情況下os並沒有安裝,需要手動安裝。
3、安裝cmake
4、安裝MySQL
..........
remove CMakeCache.txt and rerun cmake.On Debian/Ubuntu, package name is libncurses5-dev,
#如果cmake期間碰到上述錯誤,應該安裝ncurses-devel rpm包,然後移除CMakeCache.txt
#如有沒有對應的os安裝光盤,可以從下面的鏈接下載這個rpm包,注意對應的版本號應一致
SZDB:/usr/local/src/mysql_src/mysql-5.6.17 # rm -rf CMakeCache.txt
SZDB:/usr/local/src/mysql_src/mysql-5.6.17 # make
Linking CXX executable mysqltest_embedded
SZDB:/usr/local/src/mysql_src/mysql-5.6.17 # make install
..........
SZDB:/usr/local/mysql # chown -R root .
#配置環境變量,通過軟鏈或者修改環境變量實現(PATH=$PATH:/usr/local/mysql/bin/;export PATH)
#登陸到mysql
Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases;