8.4 中文镜像

MySQL 8.4 参考手册 · 中文镜像

正文为中文,英文原文默认隐藏。点击任意中文段落即可展开 / 收起对应英文原文。

打开官方英文原文 ↗

译文由机器翻译生成,仅供理解参考;有疑问请以官方英文原文为准。

MySQL 8.4 参考手册 / 2 安装 MySQL / 2.3 在 Microsoft Windows 上安装 MySQL
中文点击中文段落可显示 / 隐藏英文原文本页译文覆盖 100%

2.3 在 Microsoft Windows 上安装 MySQL2.3 Installing MySQL on Microsoft Windows

MySQL 仅适用于 Microsoft Windows 64 位操作系统。有关支持的 Windows 平台信息,请参阅 https://www.mysql.com/support/supportedplatforms/database.html。MySQL is available for Microsoft Windows 64-bit operating systems only. For supported Windows platform information, see https://www.mysql.com/support/supportedplatforms/database.html.

在 Microsoft Windows 上安装 MySQL 的方法有多种:MSI、标准二进制发行版(打包为压缩文件),其中包含您解压的所有必需文件,以及用于自行编译 MySQL 的源文件。有关相关信息,请参阅第 2.3.1 节 “选择安装包”。There are different methods to install MySQL on Microsoft Windows: the MSI, the standard binary distribution (packaged as a compressed file) containing all of the necessary files that you unpack, and source files to compile MySQL yourself. For related information, see Section 2.3.1, “Choosing an Installation Package”.

Note

MySQL 8.4 Server 需要 Microsoft Visual C++ 2019 Redistributable Package 才能在 Windows 平台上运行。在安装服务器之前,用户应确保系统上已安装该软件包。该软件包可从 Microsoft 下载中心 获取。此外,MySQL 调试二进制文件需要 Visual Studio 2019。MySQL 8.4 Server requires the Microsoft Visual C++ 2019 Redistributable Package to run on Windows platforms. Users should make sure the package has been installed on the system before installing the server. The package is available at the Microsoft Download Center. Additionally, MySQL debug binaries require Visual Studio 2019.

推荐的 MSI 安装方法Recommended MSI Installation Method

最简单且推荐的方法是下载 MSI 并让它安装 MySQL Server,然后使用它安装的 MySQL 配置器来配置 MySQL:The simplest and recommended method is to download the MSI and let it install MySQL Server, and then use the MySQL Configurator it installs to configure MySQL:

  1. 从 https://dev.mysql.com/downloads/ 并执行它。这将安装 MySQL 服务器(一个关联的 MySQL Configurator 应用程序),并将相关 MySQL 项添加到 Microsoft Windows 开始菜单的 MySQL 组下。Download the MSI from https://dev.mysql.com/downloads/ and execute it. This installs the MySQL server, an associated MySQL Configurator application, and it adds related MySQL items to the Microsoft Windows Start menu under the MySQL group.

  2. 完成后,安装向导会提示执行MySQL Configurator。立即执行(推荐)或稍后执行,或者选择手动配置 MySQL。Upon completion, the installation wizard prompts to execute MySQL Configurator. Execute it now (recommended) or later, or instead choose to manually configure MySQL.

    Note

    MySQL 服务器在配置完成后才会启动;建议在 MSI 之后立即执行捆绑的 MySQL 配置器。The MySQL server won't start until it's configured; it's recommended to execute the bundled MySQL Configurator immediately after the MSI.

MySQL 现已安装。如果您使用 MySQL Configurator 将 MySQL 配置为 Windows 服务,则每次重新启动系统时 Windows 都会自动启动 MySQL 服务器。此外,MSI 还会在本地主机上安装 MySQL 配置器应用程序,您稍后可以使用它来重新配置 MySQL 服务器。它和其他 MySQL 启动菜单项是由 MSI 添加的。MySQL is now installed. If you used MySQL Configurator to configure MySQL as a Windows service, then Windows automatically starts the MySQL server every time you restart the system. Also, the MSI installs the MySQL Configurator application on the local host, which you can use later to reconfigure MySQL server. It and other MySQL start up menu items were added by the MSI.

Microsoft Windows 上的 MySQL 安装布局MySQL Installation Layout on Microsoft Windows

对于 Windows 上的 MySQL 8.4,使用 MSI 进行安装的默认安装目录是 C:\Program Files\MySQL\MySQL Server 8.4,尽管 MSI 自定义 安装类型允许使用不同的位置。如果您使用 ZIP 压缩包的方式安装 MySQL,请安装在其他地方,例如C:\mysql。不管怎样,子目录的布局保持不变。For MySQL 8.4 on Windows, the default installation directory is C:\Program Files\MySQL\MySQL Server 8.4 for installations using the MSI, although the MSI Custom setup type allows using a different location. If you use the ZIP archive method to install MySQL, install it there are elsewhere, such as C:\mysql. Regardless, the layout of the subdirectories remains the same.

所有文件都位于此父目录中,其结构如下表所示。All of the files are located within this parent directory using the structure shown in the following table.

表 2.4 Microsoft Windows 的默认 MySQL 安装布局Table 2.4 Default MySQL Installation Layout for Microsoft Windows

目录Directory 目录内容Contents of Directory 注释Notes
binbin mysqld 服务器、客户端和实用程序mysqld server, client, and utility programs
%PROGRAMDATA%\MySQL\MySQL Server 8.4\%PROGRAMDATA%\MySQL\MySQL Server 8.4\ 日志文件、数据库Log files, databases Windows 系统变量 %PROGRAMDATA% 默认为 C:\ProgramData。The Windows system variable %PROGRAMDATA% defaults to C:\ProgramData.
docsdocs 发布文档Release documentation 对于 MSI,使用Custom类型来包含此可选组件。With the MSI, use the Custom type to include this optional component.
includeinclude 包含(标题)文件Include (header) files
liblib 库Libraries
shareshare 其他支持文件,包括错误消息、字符集文件、示例配置文件、用于数据库安装的 SQLMiscellaneous support files, including error messages, character set files, sample configuration files, SQL for database installation

静默安装方法Silent Installation Methods

使用标准用于静默安装的 msiexec 选项。此示例包括用于正常安装的 /i、用于不显示 GUI 并避免用户交互的 /qn 以及用于将详细安装输出写入新日志文件目标的 /lv。从命令行以管理员身份执行安装,例如:Use the standard msiexec options for a silent installation. This example includes /i for a normal installation, /qn to not show a GUI and to avoid user interaction, and /lv to write verbose installation output to a new log file target. Execute the installation as Administrator from the command-line, for example:

$> msiexec /i "C:\mysql\mysql-8.4.9-winx64.msi" /qn /lv "C:\mysql\install.log"

MSI 还支持 INSTALLDIR 可选择将默认安装目录路径覆盖到非默认位置。以下示例将 MySQL 安装到 C:\mysql\ 而不是 C:\Program Files\MySQL\MySQL Server 8.4\:The MSI also supports INSTALLDIR to optionally override the default installation directory path to a non-default location. The following example installs MySQL to C:\mysql\ instead of C:\Program Files\MySQL\MySQL Server 8.4\:

$> msiexec  /i "C:\mysql\mysql-8.4-winx64.msi" /qn /lv "C:\mysql\install.log" INSTALLDIR="C:\mysql"

其他安装信息Additional Installation Information

默认情况下,MySQL 配置器将 MySQL 服务器设置为 Windows 服务。通过使用服务,您可以通过标准的 Windows 服务管理工具监视和控制服务器的运行。有关手动设置 Windows 服务的相关信息,请参阅第 2.3.3.8 节“将 MySQL 作为 Windows 服务启动”。By default, MySQL Configurator sets up the MySQL server as a Windows service. By using a service, you can monitor and control the operation of the server through the standard Windows service management tools. For related information about manually setting up the Windows service, see Section 2.3.3.8, “Starting MySQL as a Windows Service”.

为了适应RESTART语句,MySQL 服务器在作为服务或独立运行时进行分叉,以启用监视器进程来监督服务器进程。在本例中,有两个 mysqld 进程。如果不需要RESTART功能,则可以使用--no-monitor选项启动服务器。请参阅第 15.7.8.8 节“RESTART 语句”。To accommodate the RESTART statement, the MySQL server forks when run as a service or standalone, to enable a monitor process to supervise the server process. In this case, there are two mysqld processes. If RESTART capability is not required, the server can be started with the --no-monitor option. See Section 15.7.8.8, “RESTART Statement”.

通常,您应该使用具有管理员权限的帐户在 Windows 上安装 MySQL。否则,您可能会遇到某些操作的问题,例如编辑 PATH 环境变量或访问服务控制管理器。安装后,MySQL 不需要使用具有管理员权限的用户来执行。Generally, you should install MySQL on Windows using an account that has administrator rights. Otherwise, you may encounter problems with certain operations such as editing the PATH environment variable or accessing the Service Control Manager. When installed, MySQL does not need to be executed using a user with Administrator privileges.

有关在 Windows 平台上使用 MySQL 的限制列表,请参阅第 2.3.6 节“Windows 平台限制”。For a list of limitations on the use of MySQL on the Windows platform, see Section 2.3.6, “Windows Platform Restrictions”.

除了 MySQL Server 软件包之外,您可能还需要或想要其他组件来使用 MySQL 您的应用程序或开发环境。这些包括但不限于:In addition to the MySQL Server package, you may need or want additional components to use MySQL with your application or development environment. These include, but are not limited to:

  • 要使用 ODBC 连接到 MySQL 服务器,您必须有连接器/ODBC 驱动程序。有关详细信息(包括安装和配置说明),请参阅 MySQL Connector/ODBC 开发人员指南。To connect to the MySQL server using ODBC, you must have a Connector/ODBC driver. For more information, including installation and configuration instructions, see MySQL Connector/ODBC Developer Guide.

  • 要将 MySQL 服务器与 .NET 应用程序一起使用,您必须具有 Connector/NET 驱动程序。有关详细信息,包括安装和配置说明,请参阅 MySQL Connector/NET 开发人员指南。To use MySQL server with .NET applications, you must have the Connector/NET driver. For more information, including installation and configuration instructions, see MySQL Connector/NET Developer Guide.

适用于 Windows 的 MySQL 发行版可以从 https://dev.mysql.com/downloads/。请参阅第 2.1.3 节“如何获取 MySQL”。MySQL distributions for Windows can be downloaded from https://dev.mysql.com/downloads/. See Section 2.1.3, “How to Get MySQL”.

Windows 版 MySQL 有多种分发格式,详细信息请参见此处。一般来说,您应该使用 MSI 来安装 MySQL 服务器并使用 MySQL 配置器来配置它。 MSI 比压缩文件更容易使用,并且您不需要额外的工具来启动和运行 MySQL。 MySQL 配置器自动配置 MySQL 服务器、创建选项文件、启动服务器、允许您创建默认用户帐户等等。有关选择软件包的更多信息,请参阅第 2.3.1 节“选择安装软件包”。MySQL for Windows is available in several distribution formats, detailed here. Generally speaking, you should use the MSI to install MySQL server and MySQL Configurator to configure it. The MSI is simpler to use than the compressed file, and you need no additional tools to get MySQL up and running. MySQL Configurator automatically configures MySQL Server, creates an options file, starts the server, enables you to create default user accounts, and more. For more information on choosing a package, see Section 2.3.1, “Choosing an Installation Package”.

Windows 上的 MySQL 注意事项MySQL on Windows Considerations

  • 大表支持Large Table Support

    如果您需要大小大于 4GB 的表,请在 NTFS 或更新的文件系统上安装 MySQL。创建表时,不要忘记使用 MAX_ROWS 和 AVG_ROW_LENGTH。请参阅第 15.1.20 节“CREATE TABLE 语句”。If you need tables with a size larger than 4GB, install MySQL on an NTFS or newer file system. Do not forget to use MAX_ROWS and AVG_ROW_LENGTH when you create tables. See Section 15.1.20, “CREATE TABLE Statement”.

  • MySQL 和病毒检查软件MySQL and Virus Checking Software

    病毒扫描软件(例如 Norton/Symantec Anti-Virus)可以对包含 MySQL 数据和临时表的目录进行扫描导致问题,包括 MySQL 的性能和病毒扫描软件将文件内容误识别为包含垃圾邮件。这是由于病毒扫描软件使用的指纹识别机制以及 MySQL 快速更新不同文件的方式造成的,这可能会被识别为潜在的安全风险。Virus-scanning software such as Norton/Symantec Anti-Virus on directories containing MySQL data and temporary tables can cause issues, both in terms of the performance of MySQL and the virus-scanning software misidentifying the contents of the files as containing spam. This is due to the fingerprinting mechanism used by the virus-scanning software, and the way in which MySQL rapidly updates different files, which may be identified as a potential security risk.

    安装 MySQL Server 后,建议您在用于存储 MySQL 表数据的主目录(datadir)上禁用病毒扫描。病毒扫描软件中通常内置一个系统,可以忽略特定目录。After installing MySQL Server, it is recommended that you disable virus scanning on the main directory (datadir) used to store your MySQL table data. There is usually a system built into the virus-scanning software to enable specific directories to be ignored.

    此外,默认情况下,MySQL 会在标准 Windows 临时目录中创建临时文件。为了防止临时文件也被扫描,请为 MySQL 临时文件配置单独的临时目录,并将该目录添加到病毒扫描排除列表中。为此,请将 tmpdir 参数的配置选项添加到 my.ini 配置文件中。有关详细信息,请参见第 2.3.3.2 节“创建选项文件”。In addition, by default, MySQL creates temporary files in the standard Windows temporary directory. To prevent the temporary files also being scanned, configure a separate temporary directory for MySQL temporary files and add this directory to the virus scanning exclusion list. To do this, add a configuration option for the tmpdir parameter to your my.ini configuration file. For more information, see Section 2.3.3.2, “Creating an Option File”.