本节提供有关使用 MySQL APT 存储库安装 MySQL 的指南。This section provides guidance on installing MySQL using the MySQL APT repository.
以下说明假设您的系统上尚未安装任何版本的 MySQL(无论是由 Oracle 还是其他方分发);如果情况并非如此,请按照使用 MySQL APT 存储库替换 MySQL 本机发行版 或 替换通过直接 deb 软件包下载安装的 MySQL 服务器。The following instructions assume that no version of MySQL (whether distributed by Oracle or other parties) has already been installed on your system; if that is not the case, follow the instructions given in Replacing a Native Distribution of MySQL Using the MySQL APT Repository or Replacing a MySQL Server Installed by a Direct deb Package Download instead.
添加 MySQL Apt 存储库。 首先,将 MySQL APT 存储库添加到系统的软件存储库列表中。请按照以下步骤操作:Adding the MySQL Apt Repository. First, add the MySQL APT repository to your system's software repository list. Follow these steps:
转到 MySQL APT 存储库的下载页面,网址为 https://dev.mysql.com/downloads/repo/apt/。Go to the download page for the MySQL APT repository at https://dev.mysql.com/downloads/repo/apt/.
选择并下载适用于您的 Linux 发行版的发行包。Select and download the release package for your Linux distribution.
尽管这不是每次更新所必需的,但它会更新 MySQL 存储库信息以包含当前的版本。信息,其中包括添加新的 LTS 系列。Although this is not required for each update, it does update MySQL repository information to include the current information, which includes adding a new LTS series.
使用以下命令安装下载的发行包,将
version-specific-package-name替换为下载的包的名称(如果您没有在包所在的文件夹中运行命令,则前面加上其路径):Install the downloaded release package with the following command, replacingversion-specific-package-namewith the name of the downloaded package (preceded by its path, if you are not running the command inside the folder where the package is):$>
sudo dpkg -i/PATH/version-specific-package-name.deb例如,对于版本
w.x.y-z包的命令是:For example, for versionw.x.y-zof the package, the command is:$>
sudo dpkg -i mysql-apt-config_w.x.y-z_all.deb请注意,同一包适用于所有受支持的 Debian 和 Ubuntu 平台。Note that the same package works on all supported Debian and Ubuntu platforms.
在安装包的过程中,系统会要求您选择要安装的 MySQL 服务器和其他组件(例如 MySQL Workbench)的版本。如果您不确定选择哪个版本,请不要更改为您选择的默认选项。如果您不想安装特定组件,也可以选择无。对所有组件进行选择后,选择确定完成发布包的配置和安装。During the installation of the package, you will be asked to choose the versions of the MySQL server and other components (for example, the MySQL Workbench) that you want to install. If you are not sure which version to choose, do not change the default options selected for you. You can also choose none if you do not want a particular component to be installed. After making the choices for all components, choose Ok to finish the configuration and installation of the release package.
Note创新轨道从 MySQL 8.1 开始,组件名称中包含“-innovation-”。The innovation track, which begins with MySQL 8.1, includes "-innovation-" in the component name.
您可以随时更改对以后版本的选择;请参阅选择主要发行版本了解说明。You can always change your choices for the versions later; see Selecting a Major Release Version for instructions.
使用以下命令从 MySQL APT 存储库更新软件包信息(此步骤是强制性的):Update package information from the MySQL APT repository with the following command (this step is mandatory):
$>
sudo apt-get update
您可以不使用发行软件包,而是可以还可以手动添加和配置 MySQL APT 存储库;有关详细信息,请参阅附录 A:手动添加和配置 MySQL APT 存储库。Instead of using the release package, you can also add and configure the MySQL APT repository manually; see Appendix A: Adding and Configuring the MySQL APT Repository Manually for details.
在您的系统上启用 MySQL APT 存储库后,您将无法再从您的平台安装任何 MySQL 软件包本地软件存储库,直到禁用 MySQL APT 存储库。Once the MySQL APT repository is enabled on your system, you will no longer be able to install any MySQL packages from your platform's native software repositories until the MySQL APT repository is disabled.
在您的系统上启用 MySQL APT 存储库后,通过 apt-get update 命令进行的任何系统范围升级都将自动升级系统上的 MySQL 软件包,并且如果 APT 在 MySQL APT 存储库中找到了替代品,则还会替换您从 Linux 发行版的软件存储库中安装的任何本机 MySQL 软件包。Once the MySQL APT repository is enabled on your system, any system-wide upgrade by the apt-get upgrade command will automatically upgrade the MySQL packages on your system and also replace any native MySQL packages you installed from your Linux distribution's software repository, if APT finds replacements for them from within the MySQL APT repository.
默认情况下,MySQL 服务器以及其他所需组件的所有安装和升级都来自您在安装配置包时选择的主要版本的发行系列(请参阅添加 MySQL Apt 存储库)。但是,您可以随时通过重新配置已安装的配置包来切换到另一个受支持的主要版本系列。使用以下命令:By default, all installations and upgrades for your MySQL server and the other required components come from the release series of the major version you have selected during the installation of the configuration package (see Adding the MySQL Apt Repository). However, you can switch to another supported major release series at any time by reconfiguring the configuration package you have installed. Use the following command:
$> sudo dpkg-reconfigure mysql-apt-config
然后会出现一个对话框,要求您选择所需的主要发行版本。做出选择并选择确定。返回命令提示符后,使用以下命令更新 MySQL APT 存储库中的软件包信息:A dialogue box then asks you to choose the major release version you want. Make your selection and choose Ok. After returning to the command prompt, update package information from the MySQL APT repository with this command:
$> sudo apt-get update
下次使用 apt-get install 命令时,将安装所选系列中的最新版本。The latest version in the selected series will then be installed when you use the apt-get install command next time.
您可以使用相同的方法更改要通过 MySQL APT 存储库安装的任何其他 MySQL 组件的版本。You can use the same method to change the version for any other MySQL component you want to install with the MySQL APT repository.
通过以下命令安装 MySQL:Install MySQL by the following command:
$> sudo apt-get install mysql-server
这将安装 MySQL 服务器的软件包,以及客户端和数据库公共文件的软件包。This installs the package for the MySQL server, as well as the packages for the client and for the database common files.
在安装过程中,系统会要求您提供 MySQL 安装的 root 用户的密码。During the installation, you are asked to supply a password for the root user for your MySQL installation.
请确保记住您设置的 root 密码。如果用户想稍后设置密码,可以将对话框中的密码字段留空,然后按确定即可;在这种情况下,对于使用 Unix 套接字文件的连接,将通过第 8.4.1.10 节“套接字对等凭据可插入身份验证” 对服务器的 root 访问进行身份验证。您可以稍后使用程序mysql_secure_installation设置 root 密码。Make sure you remember the root password you set. Users who want to set a password later can leave the password field blank in the dialogue box and just press Ok; in that case, root access to the server will be authenticated by Section 8.4.1.10, “Socket Peer-Credential Pluggable Authentication” for connections using a Unix socket file. You can set the root password later using the program mysql_secure_installation.
MySQL 服务器在安装后自动启动。您可以使用以下命令检查 MySQL 服务器的状态:The MySQL server is started automatically after installation. You can check the status of the MySQL server with the following command:
$> systemctl status mysql
如果操作系统启用了 systemd,则使用标准 systemctl(或者参数相反的 service)命令,例如 stop、start、status和restart应用于管理 MySQL 服务器服务。 mysql 服务默认启用,并在系统重新启动时启动。有关更多信息,请参阅第 2.5.9 节“使用 systemd 管理 MySQL 服务器”。If the operating system is systemd enabled, standard
systemctl (or alternatively,
service with the arguments reversed) commands
such as stop, start,
status, and restart should
be used to manage the MySQL server service. The
mysql service is enabled by default, and it
starts at system reboot. See Section 2.5.9, “Managing MySQL Server with systemd” for
additional information.
一些依赖于本机 MySQL 软件包的第三方本机存储库软件包可能无法与 MySQL APT 存储库软件包一起使用,因此不应与它们一起使用;其中包括 akonadi-backend-mysql、handlersocket-mysql-5.5 和 zoneminder。A few third-party native repository packages that have dependencies on the native MySQL packages may not work with the MySQL APT repository packages and should not be used together with them; these include akonadi-backend-mysql, handlersocket-mysql-5.5, and zoneminder.
您可以使用 APT 从 MySQL APT 存储库安装 MySQL 的各个组件。假设您的系统存储库列表中已包含 MySQL APT 存储库(有关说明,请参阅添加 MySQL APT 存储库),首先,使用以下命令从 MySQL APT 存储库获取最新的软件包信息:You can use APT to install individual components of MySQL from the MySQL APT repository. Assuming you already have the MySQL APT repository on your system's repository list (see Adding the MySQL Apt Repository for instructions), first, use the following command to get the latest package information from the MySQL APT repository:
$> sudo apt-get update
使用以下命令安装您选择的任何软件包,替换 package-name 以及要安装的包的名称:Install any packages of your choice with the following command,
replacing package-name with name of the
package to install:
$> sudo apt-get install package-name
例如,要安装 MySQL Workbench:For example, to install the MySQL Workbench:
$> sudo apt-get install mysql-workbench-community
要安装共享客户端库:To install the shared client libraries:
$> sudo apt-get install libmysqlclient21
此功能仅在 64 位系统上受支持。This feature is only supported on 64-bit systems.
您可以下载 MySQL 的源代码并使用 MySQL APT 存储库构建它:You can download the source code for MySQL and build it using the MySQL APT Repository:
将 MySQL APT 存储库添加到系统的存储库列表中,然后选择所需的主要版本系列(有关说明,请参阅添加 MySQL Apt 存储库)。Add the MySQL APT repository to your system's repository list and choose the major release series you want (see Adding the MySQL Apt Repository for instructions).
使用以下命令从 MySQL APT 存储库更新软件包信息(此步骤是强制性的):Update package information from the MySQL APT repository with the following command (this step is mandatory):
$>
sudo apt-get update安装软件包构建过程依赖于:Install packages that the build process depends on:
$>
sudo apt-get build-dep mysql-server下载 MySQL 主要组件的源代码,然后构建它们(在您想要下载的文件和构建所在的文件夹中运行此命令):Download the source code for the major components of MySQL and then build them (run this command in the folder in which you want the downloaded files and the builds to be located):
$>
apt-get source -b mysql-serverdeb软件包用于安装各种 MySQL 组件。debpackages for installing the various MySQL components are created.选择您需要的 MySQL 组件的
deb软件包,并使用命令:Pick thedebpackages for the MySQL components you need and install them with the command:$>
sudo dpkg -ipackage-name.deb注意 MySQL 包之间存在依赖关系。对于 MySQL 服务器的基本安装,请按照以下步骤安装数据库公共文件包、客户端包、客户端元包、服务器包和服务器元包(按顺序):Notice that dependency relationships exist among the MySQL packages. For a basic installation of the MySQL server, install the database common files package, the client package, the client metapackage, the server package, and the server metapackage (in that order) with the following steps:
使用以下命令预配置 MySQL 服务器包:Preconfigure the MySQL server package with the following command:
$>
sudo dpkg-preconfigure mysql-community-server_version-and-platform-specific-part.deb系统将要求您提供 MySQL 安装的 root 用户的密码;请参阅上面使用 APT 安装 MySQL 中给出的有关 root 密码的重要信息。可能还会询问您有关安装的其他问题。You will be asked to provide a password for the root user for your MySQL installation; see important information on root password given in Installing MySQL with APT above. You might also be asked other questions regarding the installation.
使用单个命令安装所需的软件包:Install the required packages with a single command:
$>
sudo dpkg -i mysql-{common,community-client,client,community-server,server}_*.deb如果 dpkg 警告您未满足的依赖项,您可以使用 apt-get 修复它们:If you are being warned of unmet dependencies by dpkg, you can fix them using apt-get:
sudo apt-get -f install
以下是文件在系统上的安装位置:Here are where the files are installed on the system:
所有配置文件(例如
my.cnf)都位于/etc/mysqlAll configuration files (likemy.cnf) are under/etc/mysql所有二进制文件、库、头文件等均位于
/usr/bin和/usr/sbinAll binaries, libraries, headers, etc., are under/usr/binand/usr/sbin数据目录位于
/var/lib/mysqlThe data directory is under/var/lib/mysql
另请参阅 启动和停止 MySQL 服务器。See also information given in Starting and Stopping the MySQL Server.
在执行任何 MySQL 升级之前,请仔细遵循第 3 章,升级 MySQL中的说明。除了那里讨论的其他说明外,在升级之前备份数据库尤其重要.Before performing any upgrade to MySQL, follow carefully the instructions in Chapter 3, Upgrading MySQL. Among other instructions discussed there, it is especially important to back up your database before the upgrade.
以下说明假设 MySQL 已使用 MySQL APT 存储库安装在您的系统上;如果情况并非如此,请按照使用 MySQL APT 存储库替换 MySQL 本机发行版 或 替换通过直接 deb 软件包下载安装的 MySQL 服务器。另请注意,您无法使用 MySQL APT 存储库升级从非本机软件存储库(例如,从 MariaDB 或 Percona)安装的 MySQL 发行版。The following instructions assume that MySQL has been installed on your system using the MySQL APT repository; if that is not the case, follow the instructions given in Replacing a Native Distribution of MySQL Using the MySQL APT Repository or Replacing a MySQL Server Installed by a Direct deb Package Download instead. Also notice that you cannot use the MySQL APT repository to upgrade a distribution of MySQL that you have installed from a nonnative software repository (for example, from MariaDB or Percona).
按照以下步骤,使用 MySQL APT 存储库对 MySQL 安装执行就地升级(即替换旧版本,然后使用旧数据文件运行新版本):Use the MySQL APT repository to perform an in-place upgrade for your MySQL installation (that is, replacing the old version and then running the new version using the old data files) by following these steps:
确保您的系统存储库列表中已包含 MySQL APT 存储库(请参阅添加 MySQL Apt 存储库(了解说明)。Make sure you already have the MySQL APT repository on your system's repository list (see Adding the MySQL Apt Repository for instructions).
通过运行以下命令确保您拥有 MySQL APT 存储库上最新的软件包信息:Make sure you have the most up-to-date package information on the MySQL APT repository by running:
$>
sudo apt-get update请注意,默认情况下,MySQL APT 存储库会将 MySQL 更新为您在时选择的版本系列。 class="link" href="linux-installation-apt-repo.html#apt-repo-setup" title="添加 MySQL APT 存储库">将 MySQL APT 存储库添加到您的系统。如果您想升级到其他版本系列,请按照选择主要发行版本中给出的步骤进行选择。Note that, by default, the MySQL APT repository will update MySQL to the release series you have selected when you were adding the MySQL APT repository to your system. If you want to upgrade to another release series, select it by following the steps given in Selecting a Major Release Version.
作为一般规则,要从一个发行系列升级到另一个发行系列,请转到下一个系列,而不是跳过一个系列。例如,如果您当前运行的是 MySQL 5.7,并希望升级到较新的系列,请先升级到 MySQL 8.0,然后再升级到 8.4。As a general rule, to upgrade from one release series to another, go to the next series rather than skipping a series. For example, if you are currently running MySQL 5.7 and wish to upgrade to a newer series, upgrade to MySQL 8.0 first before upgrading to 8.4.
ImportantMySQL APT 存储库不支持 MySQL 就地降级。按照第 4 章降级 MySQL中的说明进行操作。In-place downgrading of MySQL is not supported by the MySQL APT repository. Follow the instructions in Chapter 4, Downgrading MySQL.
通过以下命令升级 MySQL: Upgrade MySQL by the following command:
$>
sudo apt-get install mysql-server如果有新版本可用,则升级 MySQL 服务器、客户端和数据库公共文件。要升级任何其他 MySQL 软件包,请使用相同的 apt-get install 命令并提供要升级的软件包的名称:The MySQL server, client, and the database common files are upgraded if newer versions are available. To upgrade any other MySQL package, use the same apt-get install command and supply the name for the package you want to upgrade:
$>
sudo apt-get installpackage-name要查看已从 MySQL APT 存储库安装的软件包的名称,请使用以下命令:To see the names of the packages you have installed from the MySQL APT repository, use the following command:
$>
dpkg -l | grep mysql | grep iiNote如果使用 apt-get update 执行系统范围的升级,则仅升级 MySQL 库并将开发包升级为新版本(如果有)。要升级包括服务器、客户端、测试套件等在内的其他组件,请使用 apt-get install 命令。If you perform a system-wide upgrade using apt-get upgrade, only the MySQL library and development packages are upgraded with newer versions (if available). To upgrade other components including the server, client, test suite, etc., use the apt-get install command.
MySQL 服务器始终在 APT 更新后重新启动。The MySQL server always restarts after an update by APT.
MySQL 由不同各方通过自己的软件存储库或下载站点进行分发。您只需几个步骤即可将从 Linux 平台的软件存储库安装的 MySQL 本机发行版替换为 MySQL APT 存储库中的发行版。Variants and forks of MySQL are distributed by different parties through their own software repositories or download sites. You can replace a native distribution of MySQL installed from your Linux platform's software repository with a distribution from the MySQL APT repository in a few steps.
MySQL APT 存储库只能替换由 Debian 或 Ubuntu 维护和分发的 MySQL 发行版。它无法替换在发行版本机存储库内部或外部发现的任何 MySQL 分支。要替换此类 MySQL 分支,您必须先卸载它们,然后再使用 MySQL APT 存储库安装 MySQL。按照分叉分销商的卸载说明进行操作,在继续之前,请确保备份数据并且知道如何将它们恢复到新服务器。The MySQL APT repository can only replace distributions of MySQL maintained and distributed by Debian or Ubuntu. It cannot replace any MySQL forks found either inside or outside of the distributions' native repositories. To replace such MySQL forks, you have to uninstall them first before you install MySQL using the MySQL APT repository. Follow the instructions for uninstallation from the forks' distributors and, before you proceed, make sure you back up your data and you know how to restore them to a new server.
一些依赖于本机 MySQL 软件包的第三方本机存储库软件包可能无法与 MySQL APT 存储库软件包一起使用,因此不应与它们一起使用;其中包括 akonadi-backend-mysql、handlersocket-mysql-5.5 和 zoneminder。A few third-party native repository packages that have dependencies on the native MySQL packages may not work with the MySQL APT repository packages and should not be used together with them; these include akonadi-backend-mysql, handlersocket-mysql-5.5, and zoneminder.
备份数据库Backing Up Your Database
为避免数据丢失,请务必在尝试使用 MySQL APT 存储库替换 MySQL 安装之前备份数据库。有关说明,请参阅第 9 章,备份与恢复。To avoid loss of data, always back up your database before trying to replace your MySQL installation using the MySQL APT repository. See Chapter 9, Backup and Recovery for instructions.
添加 MySQL APT 存储库并选择发行系列Adding the MySQL APT Repository and Selecting a Release Series
将 MySQL APT 存储库添加到系统的存储库列表中,然后选择您想要的发行系列按照添加 MySQL Apt 存储库中给出的说明进行操作。Add the MySQL APT repository to your system's repository list and select the release series you want by following the instructions given in Adding the MySQL Apt Repository.
通过 APT 更新替换本机发行版Replacing the Native Distribution by an APT Update
根据设计,当您对 MySQL 软件包执行升级时,MySQL APT 存储库会替换您的 MySQL 本地发行版。要执行升级,请按照使用 MySQL APT 升级 MySQL 中的步骤 4 中给出的相同说明进行操作存储库。By design, the MySQL APT repository replaces your native distribution of MySQL when you perform upgrades on the MySQL packages. To perform the upgrades, follow the same instructions given in Step 4 in Upgrading MySQL with the MySQL APT Repository.
使用 MySQL APT 存储库替换 MySQL 的本机发行版后,使用 apt-get purge、apt-get remove --purge 或 dpkg 从本机存储库中清除旧的 MySQL 软件包-P 命令可能会以多种方式影响新安装的 MySQL 服务器。因此,不要从本机存储库软件包中清除旧的 MySQL 软件包。Once the native distribution of MySQL has been replaced using the MySQL APT repository, purging the old MySQL packages from the native repository using the apt-get purge, apt-get remove --purge, or dpkg -P command might impact the newly installed MySQL server in various ways. Therefore, do not purge the old MySQL packages from the native repository packages.
deb 软件包用于安装 MySQL 服务器及其组件,可以从 MySQL 开发者专区的 MySQL 下载页面 或来自 MySQL APT 存储库。两个来源的 deb 软件包不同,它们以不同的方式安装和配置 MySQL。deb packages from MySQL for installing the
MySQL server and its components can either be downloaded from the
MySQL Developer Zone's MySQL
Download page or from the MySQL APT repository. The
deb packages from the two sources are
different, and they install and configure MySQL in different ways.
如果您已使用 MySQL Developer Zone 的 deb 软件包安装了 MySQL,并且现在想要使用 MySQL APT 存储库中的软件包替换安装,请按照以下步骤操作:If you have installed MySQL with the MySQL Developer Zone's
deb packages and now want to replace the
installation using the ones from the MySQL APT repository, follow
these steps:
备份数据库。有关说明,请参阅第 9 章,备份与恢复。Back up your database. See Chapter 9, Backup and Recovery for instructions.
按照前面为添加 MySQL APT 提供的步骤操作存储库。Follow the steps given previously for adding the MySQL APT repository.
通过运行删除旧的 MySQL 安装:Remove the old installation of MySQL by running:
$>
sudo dpkg -P mysql从 MySQL APT 存储库安装 MySQL:Install MySQL from the MySQL APT repository:
$>
sudo apt-get install mysql-server如果需要,恢复新安装的 MySQL 上的数据。请参阅第 9 章,备份与恢复了解说明。If needed, restore the data on the new MySQL installation. See Chapter 9, Backup and Recovery for instructions.
使用 APT 删除 MySQLRemoving MySQL with APT
要卸载 MySQL 服务器以及使用 MySQL APT 存储库安装的相关组件,首先,使用以下命令:To uninstall the MySQL server and the related components that have been installed using the MySQL APT repository, first, remove the MySQL server using the following command:
$> sudo apt-get remove mysql-server
然后,删除随 MySQL 服务器自动安装的任何其他软件:Then, remove any other software that was installed automatically with the MySQL server:
$> sudo apt-get autoremove
要卸载其他组件,请使用以下命令,将 package-name 替换为要删除的组件的软件包名称:To uninstall other components, use the following command,
replacing package-name with the name of the
package of the component you want to remove:
$> sudo apt-get remove package-name
要查看已从 MySQL APT 存储库安装的软件包列表,请使用以下命令:To see a list of packages you have installed from the MySQL APT repository, use the following command:
$> dpkg -l | grep mysql | grep ii
升级共享客户端库的特别说明Special Notes on Upgrading the Shared Client Libraries
您可以通过以下命令从 MySQL APT 存储库安装共享客户端库(有关更多详细信息,请参阅使用 APT 安装其他 MySQL 产品和组件):You can install the shared client libraries from MySQL APT repository by the following command (see Installing Additional MySQL Products and Components with APT for more details):
$> sudo apt-get install libmysqlclient21
如果您已经从 Linux 平台的软件存储库安装了共享客户端库,则可以通过 MySQL APT 存储库对其进行更新使用相同的命令将其安装为自己的软件包(有关更多详细信息,请参阅通过 APT 更新替换本机发行版)。If you already have the shared client libraries installed from you Linux platform's software repository, it can be updated by the MySQL APT repository with its own package by using the same command (see Replacing the Native Distribution by an APT Update for more details).
使用 APT 存储库更新 MySQL 后,使用旧版本共享客户端库编译的应用程序应该可以继续工作。After updating MySQL using the APT repository, applications compiled with older versions of the shared client libraries should continue to work.
如果您重新编译应用程序并将其与更新的库动态链接:与新版本的共享库一样,使用更新的较新共享库编译的任何应用程序可能需要在部署应用程序的系统上使用这些更新的库。如果这些库没有就位,需要共享库的应用程序可能会失败。因此,建议将 MySQL 共享库的包部署在这些系统上。您可以通过将 MySQL APT 存储库添加到系统(请参阅添加 MySQL APT 存储库)并使用本节开头给出的命令安装最新的共享客户端库来完成此操作。If you recompile applications and dynamically link them with the updated libraries: as typical with new versions of shared libraries, any applications compiled using the updated, newer shared libraries might require those updated libraries on systems where the applications are deployed. If those libraries are not in place, the applications requiring the shared libraries might fail. Therefore, it is recommended that the packages for the shared libraries from MySQL be deployed on those systems. You can do this by adding the MySQL APT repository to the systems (see Adding the MySQL Apt Repository) and installing the latest shared client libraries using the command given at the beginning of this section.
MySQL APT 存储库支持在 Debian 和 Ubuntu 系统上安装 MySQL NDB Cluster。有关在其他基于 Debian 的系统上安装 NDB Cluster 的方法,请参阅使用 .deb 文件安装 NDB Cluster。The MySQL APT repository supports installation of MySQL NDB Cluster on Debian and Ubuntu systems. For methods to install NDB Cluster on other Debian-based systems, see Installing NDB Cluster Using .deb Files.
如果您的系统上已安装 MySQL 服务器或 MySQL NDB Cluster,请确保它已停止并且您已安装在继续操作之前请备份您的数据和配置文件。If you already have the MySQL server or MySQL NDB Cluster installed on your system, make sure it is stopped and you have your data and configuration files backed up before proceeding.
为 MySQL NDB Cluster 添加 MySQL APT 存储库Adding the MySQL APT Repository for MySQL NDB Cluster
按照添加 MySQL Apt 存储库中的步骤添加将 MySQL APT 存储库添加到系统的存储库列表中。在配置包安装过程中,当询问您要配置哪个 MySQL 产品时,选择“MySQL Server & Cluster”;当询问您希望接收哪个版本时,选择“mysql-cluster-
x。y。”返回命令提示符后,转到下面的步骤 2。Follow the steps in Adding the MySQL Apt Repository to add the MySQL APT repository to your system's repository list. During the installation process of the configuration package, when you are asked which MySQL product you want to configure, choose “MySQL Server & Cluster”; when asked which version you wish to receive, choose “mysql-cluster-x.y.” After returning to the command prompt, go to Step 2 below.如果您的系统上已经安装了配置包,请确保它是通过运行以下命令来更新:If you already have the configuration package installed on your system, make sure it is up-to-date by running the following command:
$>
sudo apt-get install mysql-apt-config然后,使用选择主要版本中描述的相同方法选择 MySQL NDB Cluster 进行安装。当系统询问您要配置哪个 MySQL 产品时,请选择“MySQL Server & Cluster”;当询问您希望接收哪个版本时,选择“mysql-cluster-
x。y。”返回命令提示符后,使用以下命令从 MySQL APT 存储库更新包信息:Then, use the same method described in Selecting a Major Release Version to select MySQL NDB Cluster for installation. When you are asked which MySQL product you want to configure, choose “MySQL Server & Cluster”; when asked which version you wish to receive, choose “mysql-cluster-x.y.” After returning to the command prompt, update package information from the MySQL APT repository with this command:$>
sudo apt-get update安装 MySQL NDB ClusterInstalling MySQL NDB Cluster
对于 MySQL NDB Cluster 的最小安装,请按照以下步骤操作:For a minimal installation of MySQL NDB Cluster, follow these steps:
安装 SQL 节点的组件: Install the components for SQL nodes:
$>
sudo apt-get install mysql-cluster-community-server系统将要求您提供 SQL 节点的 root 用户的密码;请参阅上面使用 APT 安装 MySQL 中给出的有关 root 密码的重要信息。可能还会询问您有关安装的其他问题。You will be asked to provide a password for the root user for your SQL node; see important information on the root password given in Installing MySQL with APT above. You might also be asked other questions regarding the installation.
安装管理节点的可执行文件:Install the executables for management nodes:
$>
sudo apt-get install mysql-cluster-community-management-server安装数据节点的可执行文件:Install the executables for data nodes:
$>
sudo apt-get install mysql-cluster-community-data-node
配置和启动 MySQL NDB ClusterConfiguring and Starting MySQL NDB Cluster
请参阅部分 25.3.3,“NDB Cluster 的初始配置”了解如何配置 MySQL NDB Cluster,以及 第 25.3.4 节,“NDB Cluster 的初始启动”了解如何首次启动它。按照这些说明进行操作时,请根据有关 NDB Cluster 安装的 SQL 节点的以下详细信息进行调整:See Section 25.3.3, “Initial Configuration of NDB Cluster” on how to configure MySQL NDB Cluster and Section 25.3.4, “Initial Startup of NDB Cluster” on how to start it for the first time. When following those instructions, adjust them according to the following details regarding the SQL nodes of your NDB Cluster installation:
所有配置文件(例如
my.cnf)都位于/etc/mysqlAll configuration files (likemy.cnf) are under/etc/mysql所有二进制文件、库、头文件等均位于
/usr/bin和/usr/sbinAll binaries, libraries, headers, etc., are under/usr/binand/usr/sbin数据目录为
/var/lib/mysqlThe data directory is/var/lib/mysql
安装其他 MySQL NDB Cluster 产品和组件Installing Additional MySQL NDB Cluster Products and Components
您可以使用 APT 从 MySQL APT 存储库安装 MySQL NDB Cluster 的各个组件和其他产品。为此,假设您的系统存储库列表中已包含 MySQL APT 存储库(请参阅 添加 MySQL NDB Cluster 的 MySQL APT 存储库),请按照 使用 APT 安装其他 MySQL 产品和组件。You can use APT to install individual components and additional products of MySQL NDB Cluster from the MySQL APT repository. To do that, assuming you already have the MySQL APT repository on your system's repository list (see Adding the MySQL Apt Repository for MySQL NDB Cluster), follow the same steps given in Installing Additional MySQL Products and Components with APT.
已知问题: 目前,在安装测试套件包时,并非会自动安装运行 MySQL NDB Cluster 测试套件所需的所有组件 (mysql-cluster-community-test)。在运行测试套件之前,使用 apt-get install 安装以下软件包:Known issue: Currently, not all
components required for running the MySQL NDB Cluster test suite are
installed automatically when you install the test suite
package (mysql-cluster-community-test).
Install the following packages with apt-get
install before you run the test suite:
mysql-cluster-community-auto-installermysql-cluster-community-auto-installermysql-cluster-community-management-servermysql-cluster-community-management-servermysql-cluster-community-data-nodemysql-cluster-community-data-nodemysql-cluster-community-memcachedmysql-cluster-community-memcachedmysql-cluster-community-javamysql-cluster-community-javandbclient-devndbclient-dev
以下是手动将 MySQL APT 存储库添加到系统的软件存储库列表中并进行配置的步骤,无需使用 MySQL 提供的发布包:Here are the steps for adding manually the MySQL APT repository to your system's software repository list and configuring it, without using the release packages provided by MySQL:
下载 MySQL GPG 公钥(请参阅第 2.1.4.2 节“使用 GnuPG 检查签名” 了解如何执行此操作)并将其保存到文件中,而不添加任何空格或特殊字符。然后,使用以下命令将密钥添加到系统的 GPG 密钥环中:Download the MySQL GPG Public key (see Section 2.1.4.2, “Signature Checking Using GnuPG” on how to do that) and save it to a file, without adding any spaces or special characters. Then, add the key to your system's GPG keyring with the following command:
$>
sudo apt-key addpath/to/signature-file或者,您可以使用 apt-key 实用程序直接将 GPG 密钥下载到 APT 密钥环中:Alternatively, you can download the GPG key to your APT keyring directly using the apt-key utility:
$>
sudo apt-key adv --keyserver pgp.mit.edu --recv-keys A8D3785CNoteMySQL 8.0.36 及更高版本包的 KeyID 为
A8D3785C,如上所示。对于早期的 MySQL 版本,keyID 为3A79BD29。使用不正确的密钥可能会导致密钥验证错误。The KeyID for MySQL 8.0.36 and later release packages isA8D3785C, as shown above. For earlier MySQL releases, the keyID is3A79BD29. Using an incorrect key can cause a key verification error.创建一个名为
/etc/apt/sources.list.d/mysql.list的文件,并按以下格式将存储库条目放入其中(这不是要执行的命令):Create a file named/etc/apt/sources.list.d/mysql.list, and put into it repository entries in the following format (this is not a command to execute):deb http://repo.mysql.com/apt/{debian|ubuntu}/ {bookworm|jammy} {mysql-tools|mysql-8.4-lts|mysql-8.0}选择存储库设置的相关选项:Pick the relevant options for your repository set up:
选择 “debian” 或 “ubuntu” 根据您的平台。Choose “debian” or “ubuntu” according to your platform.
根据您的系统版本选择合适的版本名称;示例包括 “bookworm”(对于 Debian 12)和 “jammy”(对于 Ubuntu 22.04)。Choose the appropriate version name for the version of your system; examples include “bookworm” (for Debian 12) and “jammy” (for Ubuntu 22.04).
要安装 MySQL 服务器、客户端和数据库公共文件,请选择 “mysql-8.4”、“mysql-8.0” 或 “mysql-innovation” 根据 MySQL 您想要的系列。要稍后切换到另一个版本系列,请返回并使用您的新选择调整条目。这还包括对 MySQL Router 和 MySQL Shell 等工具的访问。For installing the MySQL server, client, and database common files, choose “mysql-8.4”, “mysql-8.0”, or “mysql-innovation” according to the MySQL series you want. To switch to another release series later, come back and adjust the entry with your new choice. This also includes access to tools such as MySQL Router and MySQL Shell.
Note如果您的系统上已安装了 MySQL 版本,请不要在此步骤选择较低版本,否则可能会导致不支持的降级操作。If you already have a version of MySQL installed on your system, do not choose a lower version at this step, or it might result in an unsupported downgrade operation.
包含 “mysql-tools” 来安装连接器。Include “mysql-tools” to install a connector.
例如,在 Ubuntu 上 22.04 平台使用
mysql.list文件中的这些行从 MySQL APT 存储库安装 MySQL 8.4 和最新的 MySQL 连接器:For example, on the Ubuntu 22.04 platform use these lines in yourmysql.listfiles to install MySQL 8.4 and the latest MySQL Connectors from the MySQL APT repository:deb http://repo.mysql.com/apt/ubuntu/ jammy mysql-8.4 mysql-tools
使用以下命令从 MySQL APT 存储库获取最新的软件包信息:Use the following command to get the most up-to-date package information from the MySQL APT repository:
$>
sudo apt-get update
您已将系统配置为使用 MySQL APT 存储库,现在可以继续使用 APT 安装 MySQL 或使用 APT 安装其他 MySQL 产品和组件。You have configured your system to use the MySQL APT repository and are now ready to continue with Installing MySQL with APT or Installing Additional MySQL Products and Components with APT.