2.9.3 Installing MySQL Using a Development Source Tree

This section describes how to install MySQL from the latest development source code, which is currently hosted on both GitHub and Launchpad. To obtain the MySQL Server source code from one of these repository hosting services, you can set up a local MySQL Git repository or a local MySQL Bazaar branch.

Prerequisites for Installing from Development Source

To install MySQL from a development source tree, your system must satisfy the tool requirements outlined in Section 2.9, “Installing MySQL from Source”.

Setting Up a Local Git Repository

To set up a MySQL Git repository on your machine, use this procedure:

  1. Clone the MySQL Git repository to your machine. The following command clones the MySQL Git repository to a directory named mysql-server. The download size is approximately 437 MB. The initial download will take some time to complete, depending on the speed of your connection. Please be patient.

    ~$ git clone https://github.com/mysql/mysql-server.git 
    Cloning into 'mysql-server'...
    remote: Counting objects: 1035465, done.
    remote: Total 1035465 (delta 0), reused 0 (delta 0)
    Receiving objects: 100% (1035465/1035465), 437.48 MiB | 5.10 MiB/s, done.
    Resolving deltas: 100% (855607/855607), done.
    Checking connectivity... done.
    Checking out files: 100% (21902/21902), done.
  2. When the clone operation completes, the contents of your local MySQL Git repository appear similar to the following:

    ~$ cd mysql-server
     
    ~/mysql-server$ ls
    BUILD            COPYING             libmysqld    regex          tests
    BUILD-CMAKE      dbug                libservices  scripts        unittest
    client           Docs                man          sql            VERSION
    cmake            extra               mysql-test   sql-bench      vio
    CMakeLists.txt   include             mysys        sql-common     win
    cmd-line-utils   INSTALL-SOURCE      packaging    storage        zlib
    config.h.cmake   INSTALL-WIN-SOURCE  plugin       strings
    configure.cmake  libmysql            README       support-files
  3. Use the git branch -r command to view the remote tracking branches for the MySQL repository.

    ~/mysql-server$ git branch -r
      origin/5.5
      origin/5.6
      origin/5.7
      origin/HEAD -> origin/5.7
  4. To view the branches that are checked out in your local repository, issue the git branch command. When you cloned the MySQL Git repository, the MySQL 5.7 branch was checked out automatically. The asterisk identifies the 5.7 branch as the active branch.

    ~/mysql-server$ git branch
    * 5.7
  5. To check out a different MySQL branch, run the git checkout command, specifying the branch name. For example, to checkout the MySQL 5.5 branch:

    ~/mysql-server$ git checkout 5.5
    Branch 5.5 set up to track remote branch 5.5 from origin.
    Switched to a new branch '5.5'
  6. Run git branch again to verify that the MySQL 5.5 branch is present. MySQL 5.5, which is the last branch you checked out, is marked by an asterisk indicating that it is the active branch.

    ~/mysql-server$ git branch
    * 5.5
      5.7

    The git checkout command is also used to switch branches. For example, to make MySQL 5.7 the active branch again, you would run git checkout 5.7.

  7. To obtain changes made after your initial set up of the MySQL Git repository, switch to the branch you want to update and issue the git pull command:

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

    To examine the commit history, use the git log option:

    ~/mysql-server$ git log
    

    You can also browse commit history and source code on the GitHub MySQL site.

    If you see changes or code that you have a question about, do not hesitate to send email to the MySQL internals mailing list. See Section 1.6.1, “MySQL Mailing Lists”. For information about contributing at patch, see Contributing to MySQL Server.

  8. 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. Instructions are provided in Section 2.9.2, “Installing MySQL Using a Standard Source Distribution”, except that you skip the part about obtaining and unpacking the distribution.

    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.3, “Running Multiple MySQL Instances on One Machine”.

    Play hard with your new installation. For example, try to make new features crash. Start by running make test. See Section 24.1.2, “The MySQL Test Suite”.

Setting Up a MySQL Bazaar Branch

To setup a MySQL Bazaar branch on your machine, use this procedure:

  1. To obtain a copy of the MySQL source code, you must create a new Bazaar branch. If you do not already have a Bazaar repository directory set up, you must initialize a new directory:

    shell> mkdir mysql-server
    shell> bzr init-repo --trees mysql-server
    

    This is a one-time operation.

  2. Assuming that you have an initialized repository directory, you can branch from the public MySQL server repositories to create a local source tree. To create a branch of a specific version:

    shell> cd mysql-server
    shell> bzr branch lp:mysql-server/5.5 mysql-5.5
    

    This is a one-time operation per source tree. You can branch the source trees for several versions of MySQL under the mysql-server directory.

    The initial download will take some time to complete, depending on the speed of your connection. Once you have downloaded the first tree, additional trees should take significantly less time to download.

  3. When building from the Bazaar branch, you may want to create a copy of your active branch so that you can make configuration and other changes without affecting the original branch contents. You can achieve this by branching from the original branch:

    shell> bzr branch mysql-5.5 mysql-5.5-build
    
  4. To obtain changes made after you have set up the branch initially, update it using the pull option periodically. Use this command in the top-level directory of the local copy:

    shell> bzr pull
    

    To examine the changeset comments for the tree, use the log option to bzr:

    shell> bzr log
    

    You can also browse changesets, comments, and source code online at the Launchpad MySQL Server page.

    If you see diffs (changes) or code that you have a question about, do not hesitate to send email to the MySQL internals mailing list. See Section 1.6.1, “MySQL Mailing Lists”. For information about contributing at patch, see Contributing to MySQL Server.

  5. After you have the local branch, you can build MySQL server from the source code. Instructions are provided in Section 2.9.2, “Installing MySQL Using a Standard Source Distribution”, except that you skip the part about obtaining and unpacking the distribution.

    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.3, “Running Multiple MySQL Instances on One Machine”.

    Play hard with your new installation. For example, try to make new features crash. Start by running make test. See Section 24.1.2, “The MySQL Test Suite”.