Linux下基于源代码方式安装MySQL 5.6

摘要:
MySQL是一个开源数据库,因此可以基于源代码安装。本文介绍如何在源代码模式下安装MySQL。下载时请选择源代码。当前版本号为5.6.17#根据您自己的环境下载相应的安装介质。本文演示的安装介质是GenericLinux,mysql-5.6.17.targzhttp://dev.mysql.com/downloads/mysql/#源代码安装方法官网链接:http://dev.mysql.com/doc/refman/5.6/en/installing-source-distribution.html2,系统要求源安装系统要求从源安装MySQL需要多种开发工具。在使用标准源分发或开发源树的模式下,需要使用其中一些工具。其他工具要求取决于使用的安装方法。要从源安装MySQL,您的系统必须具有以下工具,与安装方法有关:CMake,作为建筑框架工作平台。可以下载CMakedfromhttp://www.cmake.org.Agoodmakeprogram.Althoughsomeplatformscomewiththeirownmakeimplementations,建议您使用3.75或更低的GNUmake。您的系统可以使用它。GNUmakei可用efromhttp://www.gnu.org/software/make/.AworkingANSIC++编译器。GCC4.2.1或更高版本、SunStudio12或更低版本、VisualStudio2010或更低版本以及任何当前供应商提供的编译器都是已知的。需要使用Perl来编写脚本。大多数类似于UNIX的系统包括Perl。在Windows上,可以使用诸如ActiveStatePerl之类的平均值。#有必要使用源代码安装上面的一些开发工具。最重要的是Cmake工具。通常,未安装操作系统。

    MySQL为开源数据库,因此能够基于源代码实现安装。基于源代码安装有很多其它的灵活性。

也就是说我们能够针对自己的硬件平台选用合适的编译器来优化编译后的二进制代码。依据不同的软件平台环境调整相关的编译參数。选择自身须要选择不同的安装组件,设定须要的字符集等等一些能够依据特定应用场景所作的各种调整。本文描写叙述了怎样在源代码方式下安装MySQL。

 

1、安装环境及介质
#安装环境
SZDB:~ # cat /etc/issue
Welcome to SUSE Linux Enterprise Server 10 SP3 (x86_64) - Kernel (l).
SZDB:~ # uname -a
Linux SZDB 2.6.16.60-0.54.5-smp #1 SMP Fri Sep 4 01:28:03 UTC 2009 x86_64 x86_64 x86_64 GNU/Linux

#安装介质。能够到以下网址下载安装介质。注意下载时选择source code。当前版本号为5.6.17
#依据你自身的环境下载相应的安装介质,本文演示的安装介质为Generic Linux (Architecture Independent), mysql-5.6.17.tar.gz
http://dev.mysql.com/downloads/mysql/

#源代码安装方式官方站点链接: http://dev.mysql.com/doc/refman/5.6/en/installing-source-distribution.html

 

2、系统需求
Source Installation System Requirements

  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并没有安装。须要手动安装。
#假设没有cmake会收到这个错误提示:(-bash: cmake: command not found)

 

3、安装cmake
#能够到这里下载cmake,我这里下载的是2.6.4版本号
http://www.cmake.org/cmake/resources/software.html
SZDB:~ # cd /usr/local/src/mysql_src
SZDB:/usr/local/src/mysql_src # tar -xvf cmake-2.6.4.tar.gz
SZDB:/usr/local/src/mysql_src # cd cmake-2.6.4
SZDB:/usr/local/src/mysql_src/cmake-2.6.4 # ./bootstrap 
SZDB:/usr/local/src/mysql_src/cmake-2.6.4 # ./make
SZDB:/usr/local/src/mysql_src/cmake-2.6.4 # ./make install

 

4、安装MySQL
SZDB:~ # groupadd mysql
SZDB:~ # useradd -r -g mysql mysql
SZDB:~ # cd /usr/local/src/mysql_src
SZDB:/usr/local/src/mysql_src # tar -xvf mysql-5.6.17.tar.gz
SZDB:/usr/local/src/mysql_src # ls
mysql-5.6.17  mysql-5.6.17.tar.gz
SZDB:/usr/local/src/mysql_src # cd mysql-5.6.17/
SZDB:/usr/local/src/mysql_src/mysql-5.6.17 # cmake .

             ..........
  -- Check size of wint_t - done
  -- Could NOT find Curses  (missing:  CURSES_LIBRARY CURSES_INCLUDE_PATH)
  CMake Error at cmake/readline.cmake:85 (MESSAGE):                 Author : Leshami
    Curses library not found.  Please install appropriate package,  Blog   : http://blog.csdn.net/leshami

    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:411 (MYSQL_CHECK_EDITLINE)

#假设cmake期间碰到上述错误,应该安装ncurses-devel rpm包,然后移除CMakeCache.txt
-- Configuring incomplete, errors occurred!

#如有没有相应的os安装光盘,能够从以下的链接下载这个rpm包,注意相应的版本号号应一致
http://www.filewatcher.com/m/ncurses-devel-5.5-18.11.x86_64.rpm.735840-0.html
SZDB:/usr/local/src/mysql_src # rpm -Uvh ncurses-devel-5.5-18.11.x86_64.rpm
Preparing...                ########################################### [100%]
   1:ncurses-devel          ########################################### [100%]

SZDB:/usr/local/src/mysql_src/mysql-5.6.17 # rm -rf CMakeCache.txt
SZDB:/usr/local/src/mysql_src/mysql-5.6.17 # cmake .      #再次运行cmake
             
                 ........
   -- Library mysqlserver depends on OSLIBS -lpthread;m;rt;crypt;dl;aio
   -- Configuring done
   -- Generating done
   -- Build files have been written to: /usr/local/src/mysql_src/mysql-5.6.17

SZDB:/usr/local/src/mysql_src/mysql-5.6.17 # make

   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

SZDB:/usr/local/src/mysql_src/mysql-5.6.17 # make install
SZDB:/usr/local/src/mysql_src/mysql-5.6.17 # cd /usr/local/mysql
SZDB:/usr/local/mysql # chown -R mysql .
SZDB:/usr/local/mysql # chgrp -R mysql .
SZDB:/usr/local/mysql # scripts/mysql_install_db --user=mysql

                    ..........
    To start mysqld at boot time you have to copy
    support-files/mysql.server to the right place for your system
    
    PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
    To do so, start the server, then issue the following commands:
    
      ./bin/mysqladmin -u root password 'new-password'
      ./bin/mysqladmin -u root -h SZDB password 'new-password'
    
    Alternatively you can run:
    
      ./bin/mysql_secure_installation
    
    which will also give you the option of removing the test
    databases and anonymous user created by default.  This is
    strongly recommended for production servers.
    
    See the manual for more instructions.
    
    You can start the MySQL daemon with:
    
      cd . ; ./bin/mysqld_safe &
    
    You can test the MySQL daemon with mysql-test-run.pl
    
      cd mysql-test ; perl mysql-test-run.pl
   
    New default config file was created as ./my.cnf and
    will be used by default by the server when you start it.
    You may edit this file to change server settings
         ..........

SZDB:/usr/local/mysql # chown -R root .
SZDB:/usr/local/mysql # chown -R mysql data    
SZDB:/usr/local/mysql # cp support-files/mysql.server /etc/init.d/mysql.server  #配置自启动
SZDB:/usr/local/mysql # cp support-files/my-default.cnf /etc/my.cnf             #加入缺省的my.cnf配置文件 
SZDB:/usr/local/mysql # bin/mysqld_safe --user=mysql &                          #启动mysql
[1] 21004
SZDB:/usr/local/mysql # 140521 02:54:54 mysqld_safe Logging to '/usr/local/mysql/data/SZDB.err'.
140521 02:54:54 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data

#配置环境变量,通过软链或者改动环境变量实现(PATH=$PATH:/usr/local/mysql/bin/;export PATH)
 
SZDB:~ # ln -fs /usr/local/mysql/bin/mysql /usr/local/bin 
SZDB:~ # ln -fs /usr/local/mysql/bin/mysqladmin /usr/local/bin 
SZDB:~ # ln -fs /usr/local/mysql/bin/mysqld_safe /usr/local/bin 

#登陆到mysql
SZDB:/usr/local/bin # mysql -uroot
Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 1
Server version: 5.6.17 Source distribution

Copyright (c) 2000, 2014, 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.

Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
+--------------------+
4 rows in set (0.00 sec)

免责声明:文章转载自《Linux下基于源代码方式安装MySQL 5.6》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇Mapreduce运行过程分析(基于Hadoop2.4)——(一)[Cocos2d-x v3.x]序列帧动画下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

Linux下FTP的安装和登陆

对于一个经常接触电脑的人来说,FTP无形中出现在我们生活的各个角落。日常生活中的文件上传和下载很多时候就是依靠FTP去实现的。 专业的说,FTP 是File Transfer Protocol(文件传输协议)的英文简称,而中文简称为“文传协议”。用于Internet上的控制文件的双向传输。同时,它也是一个应用程序(Application)。基于不同的...

mysql使用innodb需要注意的情况

MySql服务器一直都是不稳定,于是我就查看mysql的错误日志,具体的问题不清楚,但是确定是innodb引起的, 上网搜索了一下关于innodb的,原来要使用innodb还有一些注意事项,具体innodb使用的方法可以参考这里: www.taoer.com/doc/mydocs/database/innodb...

ZEOSDBO-7安装

zeosdbo是一套免费开源的Delphi数据库连接组件,可连接mssql、mysql、sybase、oracle、firebird、sqlite、postgresql等多种数据库。调用方法简单。 连接MySql数据库库的方法: 添加Zconnection组件,设置如下内容: Database:要连接的数据库名称; Hostname:MySQl数据库所在的主...

mysql数据库

目录 为什么使用数据库?它的优势在哪? 通过例子认识数据库 优势总结 认识数据库什么是数据库 为什么使用数据库?它的优势在哪? 将文件和程序存在一台机器上是很不合理的. 操作文件是一件很麻烦的事 通过例子认识数据库 假设现在你已经是某大型互联网公司的高级程序员,让你写一个火车票购票系统,来hold住十一期间全国的购票需求,你怎么写?...

【CentOS 6.5】【转】新版本linux生成xorg.conf

新版本的linux如何生成xorg.conf 较新版本的linux系统都已经没有xorg.conf文件,但是有时候为了对显示做微调或为了支持多屏显示等原因,还需要手工生成一个xorg.conf,然后根据情况做些修改设置。 这种情况下我们如何有一个基本的xorg.conf模板呢?当然可以从网上去找一个,然后手工修改,但是还有一种方式可以生成xorg.con...

Centos7部署kubernetes集群CA证书创建和分发(二)

1、解压软件包 [root@linux-node1 ~]# cd /usr/local/src/ [root@linux-node1 src]# ls k8s-v1.10.1-manual.zip [root@linux-node1 src]# unzip k8s-v1.10.1-manual.zip [root@linux-node1 src]# cd k...