SUSE Linux下源码编译方式安装MySQL 5.6过程分享

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)

(0)

相关推荐

  • Linux下rpm方式安装mysql教程

    每次安装总是有些不同,这次用这种方式尝试一下,也记录一下. 1.首先需要去下载rpm包: 镜像地址:http://mysql.mirrors.pair.com/Downloads/ 根据不同的版本选择下载即可,我下载的是: MySQL-server-5.6.20-1.el6.i686.rpm MySQL-client-5.6.20-1.el6.i686.rpm MySQL-devel-5.6.20-1.el6.i686.rpm(这个包备用) 因为采用rpm方式安装mysql的话,那么只安装好my

  • Linux下安装mysql-5.6.12-linux-glibc2.5-x86_64.tar.gz

    从官网下载mysql-5.6.12-linux-glibc2.5-x86_64.tar.gz 创建mysql用户 [root@Master home]# useradd mysql [root@Master data]# echo 'mysql'|passwd --stdin mysql 更改用户 mysql 的密码 . passwd: 所有的身份验证令牌已经成功更新. 创建mysql用户的原因 不用mysql用户会出现一下错误,尝试了很多次,添加mysql用户安装成功 *当然很多时候我们已经创

  • linux采用binary方式安装mysql

    本文实例为大家分享了linux采用binary方式安装mysql的具体步骤,供大家参考,具体内容如下 1.下载binary文件 在官网上下载 mysql-5.6.36-linux-glibc2.5-i686.tar.gz. 2.解压文件并移动到/usr/local/mysql目录下 tar -zxvf mysql-5.6.36-linux-glibc2.5-i686.tar.gz 3.创建用户组和用户并配置 groupadd mysql useradd mysql -g mysql chown

  • Linux下编译安装MySQL-Python教程

    1.下载mysql-python 官网地址:http://sourceforge.net/projects/mysql-python/ 2.安装mysql-python 复制代码 代码如下: # tar -zxvf MySQL-python-1.2.3.tar.gz # cd MySQL-python-1.2.3 # whereis mysql_config mysql_config: /usr/bin/mysql_config /usr/share/man/man1/mysql_config.

  • Linux下编译安装Mysql 5.5的简单步骤

    首先是安装cmake环境.因为博主测试机是ubuntu,所以直接用apt-get install cmake命令来安装,yum相信应该也一样.或者可以编译安装,步骤如下. 复制代码 代码如下: wget http://www.cmake.org/files/v2.8/cmake-2.8.12.2.tar.gz tarx zvfc cmake-2.8.12.2.tar.gz cd cmake-2.8.12.2  ./configure make && make install 安装完成后执行

  • Linux下安装Mysql多实例作为数据备份服务器实现多主到一从多实例的备份

    1.从MYSQL官方下载MYSQL的源码版本[一定要是源码版本] 2.按以下代码键入LINUX命令行 复制代码 代码如下: [注] 添加mysql组和用户 #groupadd mysql #useradd -g mysql mysql [注] 解包到/usr/local # tar -xzf mysql-standard-4.1.9-pc-linux-gnu-i686.tar.gz -C /usr/local [注] 建立软链接,方便操作(此处给此连接命名为mysql001,也可为其它的名字)

  • windows和linux安装mysql后启用日志管理功能的方法

    查看是否启用了日志 复制代码 代码如下: mysql>show variables like 'log_bin'; 怎样知道当前的日志 复制代码 代码如下: mysql> show master status; 展示二进制日志数目 复制代码 代码如下: mysql> show master logs; 看二进制日志文件用mysqlbinlog 复制代码 代码如下: shell>mysqlbinlog mail-bin.000001 或者 复制代码 代码如下: shell>my

  • 最新Linux系统下安装MySql 5.7.17全过程及注意事项

    1.cd /usr/local/ ##进入local目录 2.cp /home/soft/MySQL-5.7.15-Linux-glibc2.5-x86_64.tar.gz /usr/local/ ##拷贝mysql压缩到local目录 3.cd /usr/local/ ##进入local目录 4.tar -xzvf mysql-5.7.15-linux-glibc2.5-x86_64.tar.gz ##解压mysql压缩包 5.mv mysql-5.7.15-linux-glibc2.5-x8

  • linux安装mysql和使用c语言操作数据库的方法 c语言连接mysql

    1. MySQL的安装与配置: 在Ubuntu下安装MySQL方法很简单,使用如下命令: 复制代码 代码如下: sudo apt-get install mysql-server 安装的过程中系统会提示设置root密码,此过程可以跳过,但是建议在安装时提示设置root密码的时候自行设置,免得后面设置麻烦.安装结束之后,系统会启动mysql服务,可以使用命令去查看来验证mysql服务是否已经安装成功: 复制代码 代码如下: ps -el | grep mysql 如果mysql服务没有正常的运行,

  • Linux下安装mysql-5.6.4 的图文教程

    在开始安装前,先说明一下mysql-5.6.4与较低的版本在安装上的区别,从mysql-5.5起,mysql源码安装开始使用cmake了,因此当我们配置安装目录./configure --perfix=/.....的时候和以前的会有些区别,这点我们稍后会提到. 一:解压缩mysql-5.6.4-m7-tar.zip 1>  unzip mysql-5.6.4-m7-tar.zip   会生成mysql-5.6.4-m7-tar.gz的压缩文件 2> tar -zxvf mysql-5.6.4-

随机推荐