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;