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教程

以下是linux安装mysql的几种教程,供大家分享 安装方式1:源码安装 准备工作: 1.查看当前centos版本和内核,位数。 下载源码http://dev.mysql.com/downloads...
  • qq877507054
  • qq877507054
  • 2016年10月02日 13:00
  • 1034

【Linux】 centos 6.5 minimal 安装与配置Mysql数据库

step1:卸载掉原有mysql [root@waysoso ~]# rpm -qa | grep mysql  // 这个命令就会查看该操作系统上是否已经安装了mysql数据库 有的...
  • sinat_24420561
  • sinat_24420561
  • 2018年01月12日 23:07
  • 32

mysql的几种安装方式

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

mysql配置出现问题解决_red hat linux5.5 系统下

  • 2013年03月15日 09:54
  • 2KB
  • 下载

Red Hat Enterprise Linux 5 64位安装Mysql5.6.24(DB5.6.24.rpm for rhel5 x86)

第一步:查找以前是否装有mysql 命令:rpm -qa|grep -i mysql 结果:如果有结果代表当前系统已经安装mysql的旧版本,没有结果则没有,请跳过第二步 例如:有结果的:     ...
  • u014682191
  • u014682191
  • 2015年04月20日 20:52
  • 1389

Red Hat 安装MySQL

[root@localhost ~]# yum -y install gcc make cmake ncurses-devel libxml2-devel libtool-ltdl-devel gcc...
  • u012677972
  • u012677972
  • 2015年06月17日 15:17
  • 244

Red Hat安装MySQL之旅

背景 基于一堆已经在程序界口口相传了很多年的弃Oracle投MySQL的原因,我们的项目也决定“弃暗投明”,将数据库由Oracle迁移到MySQL,那么首要的任务就是在我们的服务器上安装MySQL...
  • VampirEM_Chosen_One
  • VampirEM_Chosen_One
  • 2016年07月06日 16:13
  • 758

linux 正确安装 mySQL全过程

操作系统:CentOS 7.2  64位 mySQL版本:mysql-5.6.35 安装过程: (1)首先从mysql官网下载 MySQL Community Server 安装包。 ...
  • hbtj_1216
  • hbtj_1216
  • 2016年12月31日 16:16
  • 5231

linux下的mysql安装(64位无需编译版)

下载mysql时,需下载对应系统的mysql版本,否则有意想不到的错误,Centos为基于redhat linux的二进制版系统,rhel为red hat enterprise linux , osx...
  • suiye
  • suiye
  • 2012年08月03日 23:10
  • 5676

RedHat Linux 6.1 安装MySQL

环境   RedHat Linux 6.1 + MySQL 5.1.7   问题   RedHat Linux 6.1安装MySQL   安装前准备   1.下载资源: MySQL-server-5....
  • Wentasy
  • Wentasy
  • 2013年04月28日 09:16
  • 7877
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:Linux之下MySQL安装的三种方案的比较
举报原因:
原因补充:

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