Linux之下MySQL安装的三种方案的比较

原创 2016年03月25日 14:04:42

如何在Linux操作系统下对MySQL进行正确的安装,以及有对不同MySQL安装的方案的比较。

其中包括使用rpm对其进行安装,二进制安装,源码安装这三种方案的比较。

  安装方法比较

  一.使用rpm安装

  安装简单,适合初学者学习使用

  1. 需要单独下载客户端和服务器

  2. 安装路径不灵活,默认路径不能修改,一台服务器只能MySQL安装一个 MySQL。

        --------------------------------下面是oracle官方文档的部分指导说明:---------------------------------

  文件布局

  MySQL Installation Layout for Linux RPM Packages from the MySQLDeveloper Zone

Directory Contents of Directory
/usr/bin Client programs and scripts
/usr/sbin The mysqld server
/var/lib/mysql Log files, databases
/usr/share/info MySQL manual in Info format
/usr/share/man Unix manual pages
/usr/include/mysql Include (header) files
/usr/lib/mysql Libraries
/usr/share/mysql Miscellaneous support files, including error messages, character set files, sample configuration files, SQL for databaseinstallation
/usr/share/sql-bench Benchmarks

 MySQL Linux RPM Package Platforms

PLATFORM Value Intended Use
linux_glibc25 Platform independent, should run on any Linux distribution that supportsglibc 2.5
rhel5 Red Hat Enterprise Linux 5
el6, el7 Enterprise Linux 6 or 7
sles11, sles12 SUSE Linux Enterprise Server 11 or 12

In MySQL 5.6, only linux_glibc2.5 packages are available currently.

The CPU value indicates the processor type or family for which the package is built, as shown in the following table.

Table 2.8 MySQL Linux RPM Package CPU Identifiers

CPU Value Intended Processor Type or Family
i386, i686 Pentium processor or better, 32 bit
x86_64 64-bit x86 processor

To see all files in an RPM package (for example, a MySQL-server RPM), run a command like this (modify the platform and CPU identifiers appropriately for your system):

shell> rpm -qpl MySQL-server-VERSION.linux_glibc2.5.i386.rpm

To perform a standard minimal installation, install the server and client RPMs:

shell> rpm -i MySQL-server-VERSION.linux_glibc2.5.i386.rpm
shell> rpm -i MySQL-client-VERSION.linux_glibc2.5.i386.rpm

To install only the client programs, install just the client RPM:

shell> rpm -i MySQL-client-VERSION.linux_glibc2.5.i386.rpm

      大多数情况下,下载MySQL-server 和MySQL-client 就够用了,安装方法如下:

  shell> rpm -ivh MySQL-server-VERSION.i386.rpm

  shell> rpm -ivh MySQL-client-VERSION.i386.rpm

  二.二进制安装

  1. 安装简单

  2. 可以地安装到任何路径下,灵活性好

  3. 一台服务器可以MySQL安装多个 MySQL

  1) 已经经过编译,性能不如源码编译的好

  2) 不能灵活定制编译参数


  ----------------------------下面是oracle官方给出的安装指导:------------------------------

       

On Unix, to install a compressed tar file binary distribution, unpack it at the installation location you choose (typically/usr/local/mysql). This creates the directories shown in the following table.

Table 2.3 MySQL Installation Layout for Generic Unix/Linux Binary Package

Directory Contents of Directory
bin, scripts mysqld server, client and utility programs
data Log files, databases
docs MySQL manual in Info format
man Unix manual pages
include Include (header) files
lib Libraries
share Miscellaneous support files, including error messages, sampleconfiguration files, SQL for database installation
sql-bench Benchmarks

Debug versions of the mysqld binary are available as mysqld-debug. To compile your own debug version of MySQL from a source distribution, use the appropriate configuration options to enable debugging support. SeeSection 2.9, “Installing MySQL from Source”.

To install and use a MySQL binary distribution, the command sequence looks like this:

shell> groupadd mysql
shell> useradd -r -g mysql -s /bin/false mysql
shell> cd /usr/local
shell> tar zxvf /path/to/mysql-VERSION-OS.tar.gz
shell> ln -s full-path-to-mysql-VERSION-OS mysql
shell> cd mysql
shell> chown -R mysql .
shell> chgrp -R mysql .
shell> scripts/mysql_install_db --user=mysql
shell> chown -R root .
shell> chown -R mysql data
shell> bin/mysqld_safe --user=mysql &
# Next command is optional
shell> cp support-files/mysql.server /etc/init.d/mysql.server

  三.源码安装

  1. 在实际安装的操作系统进行可根据需要定制编译,最灵活

  2. 性能最好

  3. 一台服务器可以安装多个 MySQL

  1. 安装过程较复杂

  2. 编译时间长

  bin客户端程序和脚本

  include/MySQL包含(头)文件

  info Info格式的文档

  lib/MySQL库

  libexec MySQLd服务器

  share/MySQL错误消息文件

  sql-bench基准程序和crash-me测试

  var数据库和日志文件

  1)去掉不需要的模块

  源码MySQL安装由于可以灵活的进行数据库的定制编译,因此有更强的灵活性。某些编译选项可以大大增强我们数据库的性能。

  执行如下命令可以看到所有编译的配置选项:

  shell> ./configure --help

  如果只安装客户端,可以执行如下命令:

  shell> ./configure --without-server

  如果你不想要位于“/usr/local/var”目录下面的日志(log)文件和数据库,使用类似于下列configure 命令的一个:

  shell>./configure--prefix=/usr/local/MySQL shell>./configure--prefix=/usr/locallocalstatedir=/usr/local/MySQL/data

  第一个命令改变安装前缀以便将所有内容MySQL安装到“/usr/local/MySQL”下面而非默认的“/usr/local”。第二个命令保留默认安装前缀,但是覆盖了数据库目录默认目录(通常是“/usr/local/var”)并且把它改为/usr/local/MySQL/data。编译完MySQL后,可以通过选项文件更改这些选项修改socket 的默认位置:

  shell> ./configure\-- with-unix-socket-path=/usr/local/MySQL/tmp/MySQL.sock

  2)只选择要使用的字符集:

  改变安装后的默认字符集和排序规则:

  shell> ./configure -- with-charset=CHARSET ./configure --with-collation=COLLATION

  选择需要MySQL安装的字符集:

  shell>./configure --with-extra-charsets=LIST

  list可以是下面任何一项:

  空格间隔的一系列字符集名

  complex -,以包括不能动态装载的所有字符集all –,以将所有字符集包括进二进制

  3)使用pgcc编译:

  pgcc 2.90.29 或更新版:

  CFLAGS="-O3 -mpentiumpro -mstack-align-double" CXX=gcc \CXXFLAGS="-O3 -mpentiumpro -mstack-align-double \-felide-constructors -fno- exceptions -fno-rtti"

  4)使用静态编译以提高性能:

  shell>./configure --with-client-ldflags=-all-static\ --with-MySQLd-ldflags=-all-static


      - ---------------------------------------oracle官方给出的指导说明--------------------------------

2.9.2 Installing MySQL Using a Standard Source Distribution

To install MySQL from a standard source distribution:

  1. Verify that your system satisfies the tool requirements listed at Section 2.9, “Installing MySQL from Source”.

  2. Obtain a distribution file using the instructions in Section 2.1.2, “How to Get MySQL”.

  3. Configure, build, and install the distribution using the instructions in this section.

  4. Perform postinstallation procedures using the instructions in Section 2.10, “Postinstallation Setup and Testing”.

In MySQL 5.6, CMake is used as the build framework on all platforms. The instructions given here should enable you to produce a working installation. For additional information on usingCMake to build MySQL, see How to Build MySQL Server with CMake.

If you start from a source RPM, use the following command to make a binary RPM that you can install. If you do not haverpmbuild, use rpm instead.

shell> rpmbuild --rebuild --clean MySQL-VERSION.src.rpm

The result is one or more binary RPM packages that you install as indicated inSection 2.5.5, “Installing MySQL on Linux Using RPM Packages from Oracle”.

The sequence for installation from a compressed tar file or Zip archive source distribution is similar to the process for installing from a generic binary distribution (seeSection 2.2, “Installing MySQL on Unix/Linux Using Generic Binaries”), except that it is used on all platforms and includes steps to configure and compile the distribution. For example, with a compressedtar file source distribution on Unix, the basic installation command sequence looks like this:

# Preconfiguration setup
shell> groupadd mysql
shell> useradd -r -g mysql -s /bin/false mysql
# Beginning of source-build specific instructions
shell> tar zxvf mysql-VERSION.tar.gz
shell> cd mysql-VERSION
shell> cmake .
shell> make
shell> make install
# End of source-build specific instructions
# Postinstallation setup
shell> cd /usr/local/mysql
shell> chown -R mysql .
shell> chgrp -R mysql .
shell> scripts/mysql_install_db --user=mysql
shell> chown -R root .
shell> chown -R mysql data
shell> bin/mysqld_safe --user=mysql &
# Next command is optional
shell> cp support-files/mysql.server /etc/init.d/mysql.server

mysql_install_db creates a default option file named my.cnf in the base installation directory. This file is created from a template included in the distribution package namedmy-default.cnf

     源码安装详细图文教程参考: http://blog.csdn.net/j7a4v5a2w2e8b9e4e6/article/details/50979167
版权声明:本文为博主原创文章,未经博主允许不得转载。

相关文章推荐

Linux安装MySQL的两种方法

1.       运行平台:CentOS 6.3 x86_64,基本等同于RHEL 6.3 2.       安装方法: 安装MySQL主要有两种方法:一种是通过源码自行编译安装,这种适合高级用户...

最全的mysql 5.7.13 安装配置方法图文教程(linux) 强烈推荐!

linux环境Mysql 5.7.13安装教程分享给大家,供大家参考,具体内容如下 1系统约定 安装文件下载目录:/data/software Mysql目录安装位置:/usr/local/...

linux 正确安装 mySQL全过程

操作系统:CentOS 7.2  64位 mySQL版本:mysql-5.6.35 安装过程: (1)首先从mysql官网下载 MySQL Community Server 安装包。 ...

mysql的几种安装方式

MySQL的几种安装方式 在学习linux的过程,学习安装软件是必不可少的,而MySQL的安装则是没有办法避免的,更何况很多公司的运维也要担任DBA的作用。 那么今天我就讲我学习linux过程中...

Linux环境安装Mysql数据库的三种方式之一:二进制包方式安装

本文是在CentOS7系统平台下安装Mysql5.6.26版本数据库的操作说明

Linux 安装 MySQL 以及 一些常见问题解决方案

一、下载MySql浏览器打开 http://www.mysql.com/downloads/mysql/#downloads 下载我下载的版本是Red Hat 5 版本的 http://www.mys...
  • catoop
  • catoop
  • 2015年09月18日 12:54
  • 5125

debian的tomcat7+mysql5.6安装

1.安装jdk sudo apt-get updatesudo apt-get install default-jresudo apt-get install default-jdk 2.安装tomc...

CentOS下MySQL两种安装方式

Linux安装MySQL主要有两种方法:一种是通过源码自行编译安装,这种适合高级用户定制MySQL的特性;另一种是通过编译过的二进制文件进行安装。二进制文件安装的方法又分为两种:一种是不针对特定平台的...

[Linux]三种方案在Windows系统下安装ubuntu双系统

原文链接:http://blog.csdn.net/pleasecallmewhy/article/details/8783657 在学习linux的过程中,ubuntu无疑是初学者的最佳选择。...
  • lasolmi
  • lasolmi
  • 2014年09月17日 19:37
  • 1103

[Linux]三种方案在Windows系统下安装ubuntu双系统

在学习linux的过程中,ubuntu无疑是初学者的最佳选择。 下面来列举给Windows系统安装ubuntu双系统的三种方法。 一、虚拟机安装(不推荐) 使用工具:Vmware 如果...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:Linux之下MySQL安装的三种方案的比较
举报原因:
原因补充:

(最多只允许输入30个字)