2.2 Installing MySQL on Unix/Linux Using Generic Binaries
2.2 在Unix/Linux上使用通用的二进制文件安装MySQL
Oracle provides a set of binary distributions of MySQL.
Oracle 提供了一组MySQL的二进制分发版.
These include binary distributions in the form of compressed tar files
(files with a .tar.gz extension) for a number of platforms, as
well as binaries in platform-specific package formats for selected
platforms.
包括以tar压缩文件形式的二进制分发版(文件以.tar.gz为后缀名),它和所选择平台的特定平台的二进制一样。
This section covers the installation of MySQL from a compressed
tar file binary distribution.
本节讨论从二进制分发版的压缩文件安装MySQL.
For other platform-specific package
formats, see the other platform-specific sections.
对于其他特定平台的包的格式,请看其他特定平台的章节。
For example,
for Windows distributions, see Section 2.3, "Installing MySQL on
Microsoft Windows."
比如,对于Windows的分发版,请看2.3章节,“在Microsoft Windows上安装MySQL”.
To obtain MySQL, see Section 2.1.3, "How to Get MySQL."
要获取MySQL,请看2.1.3章节,“如何获取MySQL”.
MySQL compressed tar file binary distributions have names of the
form mysql-VERSION-OS.tar.gz, where VERSION is a number (for
example, 5.6.20), and OS indicates the type of operating system
for which the distribution is intended (for example, pc-linux-i686
or winx64).
MySQL压缩文件二进制分发版文件名格式为mysql-VERSION-OS.tar.gz,其中VERSION是
版本号(例如,5.6.20),OS表示准备安装的分发版文件的操作系统类型(例如,
pc-linux-i686或者winx64).
To install MySQL from a compressed tar file binary distribution,
your system must have GNU gunzip to uncompress the distribution
and a reasonable tar to unpack it.
要从二进制发布版的压缩文件安装MySQL,你的系统必须有GNU gunzip来解压压缩分发版,
并且有一个合适的tar解包分发版。
If your tar program supports
the z option, it can both uncompress and unpack the file.
如果你的tar程序支持z选项,也能够解压缩文件。
GNU tar is known to work.
GUN tar据所了解,可以工作。
The standard tar provided with some
operating systems is not able to unpack the long file names in the
MySQL distribution.
一些操作系统中含有安装的tar,不能够解压MySQL分发版的长文件名。
You should download and install GNU tar, or if
available, use a preinstalled version of GNU tar.
这是你需要下载并且安装GNU tar,或者有可能,使用预装版本的GNU tar。
Usually this is
available as gnutar, gtar, or as tar within a GNU or Free Software
directory, such as /usr/sfw/bin or /usr/local/bin.
通常,这是可作为gnutar,gtar,或者使用GNU或免费的软件目录作为tar,例如
/usr/sfw/bin or /usr/local/bin。
GNU tar is available from http://www.gnu.org/software/tar/.
GNU tar可以从http://www.gnu.org/software/tar/获取。
Warning
警告
If you have previously installed MySQL using your operating system
native package management system, such as yum or apt-get, you may
experience problems installing using a native binary.
如果你之前已经使用你的操作系统的本地包管理系统安装了MySQL,比如yum或者
apt-get,你可能在使用本地二进制安装上有遗留问题。
Make sure
your previous MySQL previous installation has been removed
entirely (using your package management system), and that any
additional files, such as old versions of your data files, have
also been removed.
确保你之前安装的MySQL被全完清除了(使用包滚利系统),并且任何附加文件,
例如你数据文件的旧版本,也被删除了。
You should also check the existence of
configuration files such as /etc/my.cnf or the /etc/mysql
directory have been deleted.
你还要检查配置文件的存在,像目录/etc/my.cnf or the /etc/mysql是否被删。
If you run into problems and need to file a bug report, please use
the instructions in Section 1.7, "How to Report Bugs or Problems."
如果你遇到问题,需要提交错误报告,请使用1.7章节的说明,“如何报告错误或问题”。
On Unix, to install a compressed tar file binary distribution,
unpack it at the installation location you choose (typically
/usr/local/mysql).
在Unix上,安装一个二进制分发版的压缩文件,在你选择的安装位置解压缩它(典型的是/usr/local/mysql)。
This creates the directories shown in the
following table.
如下表所示,为创建目录。
Table 2.3 MySQL Installation Layout for Generic Unix/Linux Binary Package
表2.3是MySQL在Unix/Linux二进制包上的安装的目录结构
Directory Contents of Directory
bin Client programs and the mysqld server
data Log files, databases
docs Manual in Info format
man Unix manual pages
include Include (header) files
lib Libraries
scripts mysql_install_db
share Miscellaneous support files, including error messages,
sample configuration files, SQL for database installation
sql-bench Benchmarks
Directory | Contents of Directory |
bin | Client programs and the mysqld server |
data | Log files, databases |
docs | Manual Unix manual pagesin Info format |
man | Unix manual pages |
include | Include (header) files |
lib
Libraries | |
scripts | mysql_install_db |
share | Miscellaneous support files, including error messages, |
sample | configuration files, SQL for database installation |
sql-bench | Benchmarks |
Debug versions of the mysqld binary are available as mysqld-debug.
mysqld二进制的调试版作为mysqld-debug是可用的。
To compile your own debug version of MySQL from a source
distribution, use the appropriate configuration options to enable
debugging support.
编译你的MySQL调试版的源码,使用适当的配置选项使它支持调试。
For more information on compiling from source,
see Section 2.8, "Installing MySQL from Source."
关于更多的源码编译信息,请看2.8章节,“从源码安装MySQL”.
To install and use a MySQL binary distribution, the basic command
sequence looks like this:
安装使用MySQL二进制分发版,基本的命令序列如下:
shell> groupadd mysql
添加mysql用户组
shell> useradd -r -g mysql mysql
添加mysql用户,并制定到mysql用户组
shell> cd /usr/local
切换到/usr/local目录下
shell> tar zxvf /path/to/mysql-VERSION-OS.tar.gz
解压缩mysql-VERSION-OS.tar.gz
shell> ln -s full-path-to-mysql-VERSION-OS mysql
ln命令生成到该目录的一个符号链接,这让我们更容易的把安装目录制定为/usr/local/mysql
shell> cd mysql
切换到mysql
shell> chown -R mysql .
把数据目录的拥有权给mysql用户
shell> chgrp -R mysql .
把组的权限给mysql组
shell> scripts/mysql_install_db --user=mysql
用 mysql_install_db 创建MySQL授权表初始化
shell> chown -R root .
将文件拥有权给root
shell> chown -R mysql data
将mysql数据目录权限给mysql用户
shell> bin/mysqld_safe --user=mysql &
运行mysql,测试是否安装成功
# Next command is optional
# 下一个命令是可选的
shell> cp support-files/mysql.server /etc/init.d/mysql.server
将mysql.server复制到etc/init.d下
mysql_install_db creates a default option file named my.cnf in the
base installation directory.
mysql_install_db在基本安装目录下创建了一个名为my.cnf的默认选项文件。
This file is created from a template
included in the distribution package named my-default.cnf.
这个文件依照一个模板创建的,包括名为my-default.cnf的二进制包。
For more information, see Section 5.1.2.2, "Using a Sample Default
Server Configuration File."
需要更多的信息,请看5.1.2.2章节,“使用服务器配置文件默认样本”。
A more detailed version of the preceding description for
installing a binary distribution follows.
前面详细的描述了安装一个二进制发行版。
Note
注意
This procedure assumes that you have root (administrator) access
to your system.
这一步需要你获取系统管理员权限。
Alternatively, you can prefix each command using
the sudo (Linux) or pfexec (OpenSolaris) command.
或者你可以在每个命令前面使用sudo或者pfexec。
The procedure does not set up any passwords for MySQL accounts.
这个过程没有为MySQL账户设置任何密码。
After following the procedure, proceed to Section 2.9.2, "Securing
the Initial MySQL Accounts."
接下来请看2.9.2章节,“固定初始化MySQK账户”。
Create a mysql User and Group
创建一个mysql用户和组
If your system does not already have a user and group for mysqld
to run as, you may need to create one.
如果你的系统没有mysql的用户和组运行,你需要创建一个。
The following commands add the mysql group and the mysql user.
下面的命令是创建mysql的用户和组的。
You might want to call the user and group something else instead of mysql.
你可能想给用户和组取其他的名字而不是mysql。
If so, substitute the appropriate name in the following instructions.
如果如此,使用相应的名字替代下面的说明。
The syntax for
useradd and groupadd may differ slightly on different versions of
Unix, or they may have different names such as adduser and
addgroup.
在不同版本的Unix系统上,创建用户和组的语法可能略微有些不同,
或者有不同的叫法,例如adduser和addgroup。
shell> groupadd mysql
shell> useradd -r -g mysql mysql
Note
注意
Because the user is required only for ownership purposes, not
login purposes, the useradd command uses the -r option to create a
user that does not have login permissions to your server host.
因为用户的目的只是拥有所有权,而不是进入系统,useradd命令使用-r选项
来创建一个没有登录服务器主机权限的用户。
Omit this option to permit logins for the user (or if your useradd
does not support the option).
不使用这个选项就允许用户登录(或者你的useradd不支持这个选项)。
Obtain and Unpack the Distribution
获取并且解压缩发布版
Pick the directory under which you want to unpack the distribution
and change location into it.
在你希望解压缩发布版的目录下解压。
The example here unpacks the distribution under /usr/local.
例如:/usr/local
The instructions, therefore, assume
that you have permission to create files and directories in
/usr/local.
这个指令的前提是你有权限在/usr/local下创建文件和目录
If that directory is protected, you must perform the
installation as root.
如果这个目录被保护,你必须使用超级管理员权限执行。
shell> cd /usr/local
Obtain a distribution file using the instructions in Section
2.1.3, "How to Get MySQL."
使用2.1.3章节“如何获取mysql”来获取一个分布文件。
For a given release, binary
distributions for all platforms are built from the same MySQL
source distribution.
对于一个给定的释放,所有平台的分布版的创建都来自与同一个MySQL源分布。
Unpack the distribution, which creates the installation directory.
解压分布版,它会为我们创建安装目录。
Then create a symbolic link to that directory.
然后创建一个符号链接目录。
tar can uncompress and unpack the distribution if it has z option support:
tar命令如果支持z选项,它就可以解压分布版。
shell> tar zxvf /path/to/mysql-VERSION-OS.tar.gz
shell> ln -s full-path-to-mysql-VERSION-OS mysql
The tar command creates a directory named mysql-VERSION-OS.
tar命令创建了一个名为mysql-VERSION-OS的目录。
The ln command makes a symbolic link to that directory.
ln命令为该目录创建了一个符号链接。
This enables you
to refer more easily to the installation directory as
/usr/local/mysql.
这使你更容易的使用安装目录如/usr/local/mysql。
If your tar does not have z option support, use gunzip to unpack
the distribution and tar to unpack it.
如果你的tar没有z选项的支持,使用gunzip来解压缩分布版和tar来解压它。
Replace the preceding tar
command with the following alternative command to uncompress and
extract the distribution:
使用下面的命令来代替之前的命令来解压并提取目录。
shell> gunzip < /path/to/mysql-VERSION-OS.tar.gz | tar xvf -
Perform Postinstallation Setup
执行安装后的配置
The remainder of the installation process involves setting up the
configuration file, creating the core databases, and starting the
MySQL server.
剩下的安装过程包括设置配置文件,创建核心数据库,启动mysql服务器。
For next steps, see Section 2.9, "Postinstallation
Setup and Testing."
下面的步骤,参照2.9节“安装后的设置与测试”
Note
注意
The accounts that are listed in the MySQL grant tables initially
have no passwords.
在MySQL grant的表里面初始化列出的账户没有密码。
After starting the server, you should set up
passwords for them using the instructions in Section 2.9.2,
"Securing the Initial MySQL Accounts."
在启动服务气候,你应该参照2.9.2节“安全初始化MySQL账户”,为它们设置密码。
Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights
reserved. Legal Notices