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

时间:2021-12-17 22:49:48

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

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

1、安装环境及介质
#安装环境
SZDB:~ # cat /etc/issue
Welcome to SUSE Linux Enterprise Server 10 SP3 (x86_64) - Kernel \r (\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的更多相关文章

  1. Linux下通用二进制方式安装MySQL

    1.下载glibc版本的MySQL: https://downloads.mysql.com/archives/community/ 2.查看mysql用户和mysql组是否存在(用户和组的信息存在/ ...

  2. Linux下用rpm方式安装MySQL

    1.MySQL下载地址. www.mysql.com/downloads/mysql-4.0.html 下载MySQL 5.1版本的2个包(根据你的实际需求下载所需要的包): MySQL-server ...

  3. CentOS7下通过rpm方式安装MySQL及插入中文问题解决 [原创]

    一 CentOS下通过rpm方式安装MySQL CentOS版本:CentOS-7 MySQL版本:MySQL-5.6.22 在网上搜了一下,Linux下安装MYSQL有三种方式: 1) 通过yum命 ...

  4. [转]在ubuntu linux下以编译方式安装LAMP(apache mysql php)环境

    FROM : http://www.cnblogs.com/eleganthqy/archive/2010/02/28/1675217.html 最近转向到了使用ubuntu做桌面,安装好系统以来一直 ...

  5. 在Windows下通过压缩包方式安装MySQL

    需求:下载MySQL有两种方法,一是下载可执行文件,通过点点点的方式,比较简单没什么技术含量,但是之前通过此方法下载的MySQL与Python进行连接交互的时候总是报1045错误,一直没找到原因,尝试 ...

  6. Linux 下使用yum 命令安装MySQL

    Linux下使用yum安装MySQL,以及启动.登录和远程访问MySQL数据库. 1.yum安装mysql 1. 查看有没有安装包:   yum list mysql*    #移除已经安装的mysq ...

  7. Centos6 系统下源码方式安装Mysql 记录

    在运维工作中经常部署各种运维环境,涉及mysql数据库的安装也是时常需要的.mysql数据库安装可以选择yum在线安装,但是这种安装的mysql一般是系统自带的,版本方面可能跟需求不太匹配. #### ...

  8. linux使用yum的方式安装mysql实践

    1.先检测是否已安装mysql ps -ef|grep mysql root : pts/ :: /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mys ...

  9. Linux下源码编译安装MySql,centeros7

    1. 安cmake工具 # yum install -y cmake 2. 创建mysql用户  #useradd -s /sbin/nologin mysql  //设置为非登陆用户(安全) 3. ...

随机推荐

  1. NGINX: 405 Not Allowed

    近期做一个手机端静态网站,在wcm上网站预览的时候显示正常,网站数据发布到nginx网站服务上后,发现页面有部分不显示: 正常页面: 错误页面: 进入谷歌浏览器的Developer Tools(F12 ...

  2. UITableView swift

    // // ViewController.swift // UILabelTest // // Created by mac on 15/6/23. // Copyright (c) 2015年 fa ...

  3. 2011 ACM/ICPC 成都赛区(为2013/10/20成都现场赛Fighting)

    hdu 4111  Alice and Bob 博弈:http://www.cnblogs.com/XDJjy/p/3350014.html hdu 4112 Break the Chocolate ...

  4. ios开发之C语言第一天

    最近在学习ios开发,先学习C语言,再学习OC和swift.正所谓"万丈高楼平地起",打好基础是很重要的,所以C语言也必须好好学习.学习中所使用的操作系统是OS X,开发工具是Xc ...

  5. android——fragment长时间home或者锁屏java.lang.IllegalArgumentException:No view found for id for....

    在项目中遇到了这个问题.头痛了很久,总是无法重现,也不能很好的解决.总是在息屏后一段时间,就会报java.lang.IllegalArgumentException:No view found for ...

  6. JavaWeb学习总结(二)——Tomcat服务器学习和使用(一)(转)

    转载自 http://www.cnblogs.com/xdp-gacl/p/3734395.html 一.Tomcat服务器端口的配置 Tomcat的所有配置都放在conf文件夹之中,里面的serve ...

  7. pageUtil分页工具

    分页工具: https://www.cnblogs.com/ggq-insist-qiang/articles/10095603.html

  8. [04] Bean的实例化和多个配置文件

    之前我们已经提到过,Spring的核心能力之一就是IOC机制,从上章的示例中我们也可以看到,Spring中的ApplicationContext充当了一个实例化对象的容器的角色,并管理着它们的生命周期 ...

  9. python string.py 源码分析 二:capwords

    def capwords(s, sep=None): """capwords(s [,sep]) -> string Split the argument into ...

  10. css3边框与背景

    一.css3边框 1.border-image 边框 border-image: url(xxx.png) number stretch 很好理解就是拉伸,有多长拉多长. repeat (和4角上 同 ...