Oracle provides a set of binary distributions of MySQL. Oracle提供了一组MySQL的二进制发行版。These include generic binary distributions in the form of compressed tar files (files with a 其中包括用于许多平台的压缩tar文件(扩展名为.tar.xz
extension) for a number of platforms, and binaries in platform-specific package formats for selected platforms..tar.xz
的文件)形式的通用二进制发行版,以及用于选定平台的特定于平台的包格式的二进制发行版。
This section covers the installation of MySQL from a compressed tar file binary distribution on Unix/Linux platforms. 本节介绍在Unix/Linux平台上从压缩的tar文件二进制分发版安装MySQL。For Linux-generic binary distribution installation instructions with a focus on MySQL security features, refer to the Secure Deployment Guide. For other platform-specific binary package formats, see the other platform-specific sections in this manual. 有关Linux通用二进制分发版的安装说明,重点是MySQL的安全功能,请参阅《安全部署指南》。有关其他平台特定的二进制包格式,请参阅本手册中其他平台特定部分。For example, for Windows distributions, see Section 2.3, “Installing MySQL on Microsoft Windows”. 例如,对于Windows发行版,请参阅第2.3节,“在Microsoft Windows上安装MySQL”。See Section 2.1.3, “How to Get MySQL” on how to obtain MySQL in different distribution formats.关于如何获得不同分发格式的MySQL,请参阅第2.1.3节,“如何获得MySQL”。
MySQL compressed tar file binary distributions have names of the form MySQL压缩的tar文件二进制发行版的名称格式为mysql-
, where VERSION
-OS
.tar.xz
is a number (for example, VERSION
8.0.25
), and OS
indicates the type of operating system for which the distribution is intended (for example, pc-linux-i686
or winx64
).mysql-VERSION-OS.tar.xz
,其中VERSION
是一个数字(例如,8.0.25),OS表示发行版所针对的操作系统类型(例如,pc-linux-i686
或winx64
)。
There is also a “minimal install” version of the MySQL compressed tar file for the Linux generic binary distribution, which has a name of the form 还有一个用于Linux通用二进制发行版的MySQL压缩tar文件的“最小安装”版本,其名称形式为mysql-
. VERSION
-OS
-GLIBCVER
-ARCH
-minimal.tar.xzmysql-VERSION-OS-GLIBCVER-ARCH-minimal.tar.xz
。The minimal install distribution excludes debug binaries and is stripped of debug symbols, making it significantly smaller than the regular binary distribution. 最小安装发行版不包括调试二进制文件,并且去掉了调试符号,使其明显小于常规二进制发行版。If you choose to install the minimal install distribution, remember to adjust for the difference in file name format in the instructions that follow.如果您选择安装最低安装发行版,请记住在以下说明中根据文件名格式的差异进行调整。
If you have previously installed MySQL using your operating system native package management system, such as Yum or APT, you may experience problems installing using a native binary. 如果您以前使用操作系统本机包管理系统(如Yum或APT)安装过MySQL,则使用本机二进制文件安装时可能会遇到问题。Make sure your previous MySQL 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 for configuration files such as 您还应该检查/etc/my.cnf
or the /etc/mysql
directory and delete them./etc/my.cnf
或/etc/mysql
目录等配置文件并将其删除。
For information about replacing third-party packages with official MySQL packages, see the related APT guide or Yum guide.有关用官方MySQL包替换第三方包的信息,请参阅相关的APT指南或Yum指南。
MySQL has a dependency on the MySQL依赖于libaio
library. Data directory initialization and subsequent server startup steps fail if this library is not installed locally. libaio
库。如果未在本地安装此库,则数据目录初始化和随后的服务器启动步骤将失败。If necessary, install it using the appropriate package manager. For example, on Yum-based systems:如有必要,请使用相应的软件包管理器进行安装。例如,在基于百胜的系统上:
shell>yum search libaio
# search for info shell>yum install libaio
# install library
Or, on APT-based systems:或者,在基于APT的系统上:
shell>apt-cache search libaio
# search for info shell>apt-get install libaio1
# install library
Oracle Linux 8 / Red Hat 8 (EL8): These platforms by default do not install the file (EL8):默认情况下,这些平台不安装文件/lib64/libtinfo.so.5
, which is required by the MySQL client bin/mysql for packages mysql-VERSION-el7-x86_64.tar.gz
and mysql-VERSION-linux-glibc2.12-x86_64.tar.xz
. /lib64/libtinfo.so.5
,这是MySQL客户端bin/mysql对包mysql-VERSION-el7-x86_64.tar.gz
和mysql-VERSION-linux-glibc2.12-x86_64.tar.xz
所要求的。To work around this issue, install the 要解决此问题,请安装ncurses-compat-libs
package:ncurses-compat-libs
包:
shell> yum install ncurses-compat-libs
To install a compressed tar file binary distribution, unpack it at the installation location you choose (typically 要安装压缩的tar文件二进制分发版,请在您选择的安装位置(通常为/usr/local/mysql
). /usr/local/mysql
)对其进行解压缩。This creates the directories shown in the following table.这将创建下表中所示的目录。
Table 2.3 MySQL Installation Layout for Generic Unix/Linux Binary Package通用Unix/Linux二进制包的MySQL安装布局
bin | mysqld server, client and utility programs |
docs | |
man | |
include | |
lib | |
share | |
support-files |
Debug versions of the mysqld binary are available as mysqld-debug. mysqld二进制文件的调试版本可用作mysqld调试。To compile your own debug version of MySQL from a source distribution, use the appropriate configuration options to enable debugging support. See Section 2.9, “Installing MySQL from Source”.要从源发行版编译您自己的MySQL调试版本,请使用适当的配置选项来启用调试支持。请参阅第2.9节,“从源代码安装MySQL”。
To install and use a MySQL binary distribution, the command sequence looks like this:要安装和使用MySQL二进制分发版,命令序列如下所示:
shell>groupadd mysql
shell>useradd -r -g mysql -s /bin/false mysql
shell>cd /usr/local
shell>tar xvf
shell>/path/to/mysql-VERSION-OS
.tar.xzln -s
shell>full-path-to-mysql-VERSION-OS
mysqlcd mysql
shell>mkdir mysql-files
shell>chown mysql:mysql mysql-files
shell>chmod 750 mysql-files
shell>bin/mysqld --initialize --user=mysql
shell>bin/mysql_ssl_rsa_setup
shell>bin/mysqld_safe --user=mysql &
# Next command is optional shell>cp support-files/mysql.server /etc/init.d/mysql.server
This procedure assumes that you have 此过程假定您对系统具有root
(administrator) access to your system. root
(管理员)访问权限。Alternatively, you can prefix each command using the sudo (Linux) or pfexec (Solaris) command.或者,您可以使用sudo(Linux)或pfexec(Solaris)命令为每个命令加前缀。
The mysql-files
directory provides a convenient location to use as the value for the secure_file_priv
system variable, which limits import and export operations to a specific directory. mysql-files
目录提供了一个方便的位置,可以用作secure_file_priv
系统变量的值,该变量将导入和导出操作限制在特定目录中。See Section 5.1.8, “Server System Variables”.请参阅第5.1.8节,“服务器系统变量”。
A more detailed version of the preceding description for installing a binary distribution follows.下面是前面关于安装二进制发行版的描述的更详细版本。
If your system does not already have a user and group to use for running mysqld, you may need to create them. 如果您的系统还没有用于运行mysqld的用户和组,则可能需要创建它们。The following commands add the 以下命令添加mysql
group and the mysql
user. mysql
组和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/Linux, or they may have different names such as adduser and addgroup.在不同版本的Unix/Linux上,useradd和groupadd的语法可能略有不同,也可能有不同的名称,如adduser和addgroup。
shell>groupadd mysql
shell>useradd -r -g mysql -s /bin/false mysql
Because the user is required only for ownership purposes, not login purposes, the useradd command uses the 由于用户仅用于所有权目的而非登录目的,因此useradd命令使用-r
and -s /bin/false
options to create a user that does not have login permissions to your server host. -r
和-s /bin/false
选项来创建一个没有服务器主机登录权限的用户。Omit these options if your useradd does not support them.如果您的useradd不支持这些选项,请省略它们。
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
.root
用户身份执行安装。
shell> cd /usr/local
Obtain a distribution file using the instructions in Section 2.1.3, “How to Get MySQL”. For a given release, binary distributions for all platforms are built from the same MySQL source distribution.使用第2.1.3节,“如何获取MySQL”中的说明获取分发文件。对于给定的发行版,所有平台的二进制发行版都是从相同的MySQL源发行版构建的。
Unpack the distribution, which creates the installation directory. 解压缩分发版,这将创建安装目录。tar can uncompress and unpack the distribution if it has 如果发行版支持z
option support:z
选项,则可以解压缩和解包:
shell> tar xvf /path/to/mysql-VERSION-OS
.tar.xz
The tar command creates a directory named tar命令创建一个名为mysql-
.VERSION
-OS
mysql-VERSION-OS
的目录。
To install MySQL from a compressed tar file binary distribution, your system must have GNU 要从压缩的tar文件二进制分发版安装MySQL,您的系统必须有GNU XZ Utils
to uncompress the distribution and a reasonable tar to unpack it.XZ Utils
来解压缩分发版,并有一个合理的tar来解压缩它。
The compression algorithm changed from Gzip to XZ in MySQL Server 8.0.12; and the generic binary's file extension changed from .tar.gz to .tar.xz.MySQL Server 8.0.12中的压缩算法由Gzip改为XZ;通用二进制文件的文件扩展名从.tar.gz
更改为.tar.xz
。
GNU tar is known to work. 众所周知,GNU 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 通常,它在GNU或自由软件目录(如/usr/sfw/bin
or /usr/local/bin
. /usr/sfw/bin
或/usr/local/bin
)中以gnutar、gtar或tar的形式提供。GNU tar is available from http://www.gnu.org/software/tar/.GNU tar可从http://www.gnu.org/software/tar/下载到。
If your tar does not support the 如果您的tar不支持xz
format then use the xz command to unpack the distribution and tar to unpack it. xz
格式,则使用xz命令对分发文件进行解包,然后使用tar对其进行解包。Replace the preceding tar command with the following alternative command to uncompress and extract the distribution:用以下替代命令替换前面的tar命令,以解压缩和提取分发:
shell> xz -dc /path/to/mysql-VERSION-OS
.tar.xz | tar x
Next, create a symbolic link to the installation directory created by tar:接下来,创建一个指向tar创建的安装目录的符号链接:
shell> ln -s full-path-to-mysql-VERSION-OS
mysql
The ln
command makes a symbolic link to the installation directory. ln
命令生成到安装目录的符号链接。This enables you to refer more easily to it as 这使您能够更容易地将其称为/usr/local/mysql
. /usr/local/mysql
。To avoid having to type the path name of client programs always when you are working with MySQL, you can add the 为了避免在使用MySQL时总是键入客户端程序的路径名,可以将/usr/local/mysql/bin
directory to your PATH
variable:/usr/local/MySQL/bin
目录添加到path
变量中:
shell> export PATH=$PATH:/usr/local/mysql/bin
The remainder of the installation process involves setting distribution ownership and access permissions, initializing the data directory, starting the MySQL server, and setting up the configuration file. 安装过程的其余部分包括设置分发所有权和访问权限、初始化数据目录、启动MySQL服务器以及设置配置文件。For instructions, see Section 2.10, “Postinstallation Setup and Testing”.有关说明,请参阅第2.10节,“安装后设置和测试”。