2.9.5 Installing MySQL Using a Development Source Tree使用开发源目录树安装MySQL

This section describes how to install MySQL from the latest development source code, which is hosted on GitHub. To obtain the MySQL Server source code from this repository hosting service, you can set up a local MySQL Git repository.本节介绍如何从托管在GitHub上的最新开发源代码安装MySQL。要从这个存储库托管服务中获取MySQL Server源代码,您可以设置一个本地MySQL Git存储库。

On GitHub, MySQL Server and other MySQL projects are found on the MySQL page. The MySQL Server project is a single repository that contains branches for several MySQL series.在GitHub上,MySQL Server和其他MySQL项目可以在MySQL页面上找到。MySQL Server项目是一个单独的存储库,其中包含多个MySQL系列的分支。

MySQL officially joined GitHub in September, 2014. For more information about MySQL's move to GitHub, refer to the announcement on the MySQL Release Engineering blog: MySQL于2014年9月正式加入GitHub。有关MySQL迁移到GitHub的更多信息,请参阅MySQL Release Engineering博客上的公告:MySQL on GitHub

Prerequisites for Installing from Development Source从开发源安装的先决条件

To install MySQL from a development source tree, your system must satisfy the tool requirements listed at Section 2.9.2, “Source Installation Prerequisites”.要从开发源代码树安装MySQL,您的系统必须满足第2.9.2节,“源代码安装先决条件”中列出的工具要求

Setting Up a MySQL Git Repository设置MySQL Git存储库

To set up a MySQL Git repository on your machine:要在您的机器上设置MySQL Git存储库,请执行以下操作:

  1. Clone the MySQL Git repository to your machine. The following command clones the MySQL Git repository to a directory named mysql-server. 将MySQL Git存储库克隆到您的机器上。以下命令将MySQL Git存储库克隆到名为mysql-server的目录中。The initial download may take some time to complete, depending on the speed of your connection.初始下载可能需要一些时间才能完成,具体取决于您的连接速度。

    ~$ git clone https://github.com/mysql/mysql-server.git
    Cloning into 'mysql-server'...
    remote: Counting objects: 1198513, done.
    remote: Total 1198513 (delta 0), reused 0 (delta 0), pack-reused 1198513
    Receiving objects: 100% (1198513/1198513), 1.01 GiB | 7.44 MiB/s, done.
    Resolving deltas: 100% (993200/993200), done.
    Checking connectivity... done.
    Checking out files: 100% (25510/25510), done.
  2. When the clone operation completes, the contents of your local MySQL Git repository appear similar to the following:克隆操作完成后,本地MySQL Git存储库的内容显示如下:

    ~$ cd mysql-server
    ~/mysql-server$ ls
    client             extra                mysys              storage
    cmake              include              packaging          strings
    CMakeLists.txt     INSTALL              plugin             support-files
    components         libbinlogevents      README             testclients
    config.h.cmake     libbinlogstandalone  router             unittest
    configure.cmake    libmysql             run_doxygen.cmake  utilities
    Docs               libservices          scripts            VERSION
    Doxyfile-ignored   LICENSE              share              vio
    Doxyfile.in        man                  sql                win
    doxygen_resources  mysql-test           sql-common
  3. Use the git branch -r command to view the remote tracking branches for the MySQL repository.使用git branch -r命令可以查看MySQL存储库的远程跟踪分支。

    ~/mysql-server$ git branch -r
      origin/5.5
      origin/5.6
      origin/5.7
      origin/8.0
      origin/HEAD -> origin/8.0
      origin/cluster-7.2
      origin/cluster-7.3
      origin/cluster-7.4
      origin/cluster-7.5
      origin/cluster-7.6
  4. To view the branch that is checked out in your local repository, issue the git branch command. 要查看在本地存储库中签出的分支,请发出git branch命令。When you clone the MySQL Git repository, the latest MySQL GA branch is checked out automatically. The asterisk identifies the active branch.当您克隆MySQL Git存储库时,会自动检出最新的MySQL GA分支。星号表示活动分支。

    ~/mysql-server$ git branch
    * 8.0
  5. To check out an earlier MySQL branch, run the git checkout command, specifying the branch name. For example, to check out the MySQL 5.7 branch:要签出早期的MySQL分支,请运行git checkout命令,指定分支名称。例如,要查看MySQL 5.7分支:

    ~/mysql-server$ git checkout 5.7
    Checking out files: 100% (9600/9600), done.
    Branch 5.7 set up to track remote branch 5.7 from origin.
    Switched to a new branch '5.7'
  6. To obtain changes made after your initial setup of the MySQL Git repository, switch to the branch you want to update and issue the git pull command:要获得MySQL Git存储库初始设置后所做的更改,请切换到要更新的分支,并发出Git pull命令:

    ~/mysql-server$ git checkout 8.0
    ~/mysql-server$ git pull

    To examine the commit history, use the git log option:要检查提交历史记录,请使用git log选项:

    ~/mysql-server$ git log

    You can also browse commit history and source code on the GitHub MySQL site.您也可以在GitHub MySQL网站上浏览提交历史记录和源代码。

    If you see changes or code that you have a question about, ask on the MySQL Community Slack. For information about contributing a patch, see Contributing to MySQL Server.如果您看到有问题的更改或代码,请在MySQL社区Slack上询问。有关贡献补丁的信息,请参阅贡献到MySQL Server

  7. After you have cloned the MySQL Git repository and have checked out the branch you want to build, you can build MySQL Server from the source code. 在您克隆了MySQL Git存储库并签出了要构建的分支之后,您可以从源代码构建MySQL Server。Instructions are provided in Section 2.9.4, “Installing MySQL Using a Standard Source Distribution”, except that you skip the part about obtaining and unpacking the distribution.第2.9.4节,“使用标准源发行版安装MySQL”提供了相关说明,但您可以跳过有关获取和解包发行版的部分。

    Be careful about installing a build from a distribution source tree on a production machine. The installation command may overwrite your live release installation. 在生产计算机上安装来自分发源树的生成时要小心。安装命令可能会覆盖您的实时版本安装。If you already have MySQL installed and do not want to overwrite it, run CMake with values for the CMAKE_INSTALL_PREFIX, MYSQL_TCP_PORT, and MYSQL_UNIX_ADDR options different from those used by your production server. For additional information about preventing multiple servers from interfering with each other, see Section 5.8, “Running Multiple MySQL Instances on One Machine”.如果您已经安装了MySQL,并且不想覆盖它,请使用与生产服务器使用的CMAKE_INSTALL_PRIIXMySQL_TCP_PORTMySQL_UNIX_ADDR选项不同的值运行CMake。有关防止多个服务器相互干扰的更多信息,请参阅第5.8节,“在一台机器上运行多个MySQL实例”

    Play hard with your new installation. For example, try to make new features crash. 认真使用您的新安装。例如,尝试使新功能崩溃。Start by running make test. See The MySQL Test Suite.首先运行make test。请参阅MySQL测试套件