Documentation Home
MySQL 5.7 Reference Manual
Related Documentation Download this Manual
PDF (US Ltr) - 35.1Mb
PDF (A4) - 35.2Mb
Man Pages (TGZ) - 256.4Kb
Man Pages (Zip) - 361.2Kb
Info (Gzip) - 3.4Mb
Info (Zip) - 3.4Mb
Excerpts from this Manual

MySQL 5.7 Reference Manual  / ...  / Installing and Upgrading MySQL  / Installing MySQL from Source  /  Installing MySQL Using a Standard Source Distribution

2.8.4 Installing MySQL Using a Standard Source Distribution

To install MySQL from a standard source distribution:

  1. Verify that your system satisfies the tool requirements listed atSection 2.8.2, “Source Installation Prerequisites”.

  2. Obtain a distribution file using the instructions inSection 2.1.3, “How to Get MySQL”.

  3. Configure, build, and install the distribution using the instructions in this section.

  4. Perform postinstallation procedures using the instructions inSection 2.9, “Postinstallation Setup and Testing”.

MySQL usesCMake as the build framework on all platforms. The instructions given here should enable you to produce a working installation. For additional information on usingCMake to build MySQL, seeHow to Build MySQL Server with CMake.

If you start from a source RPM, use the following command to make a binary RPM that you can install. If you do not haverpmbuild, userpm instead.

$> rpmbuild --rebuild --clean MySQL-VERSION.src.rpm

The result is one or more binary RPM packages that you install as indicated inSection 2.5.5, “Installing MySQL on Linux Using RPM Packages from Oracle”.

The sequence for installation from a compressedtar file or Zip archive source distribution is similar to the process for installing from a generic binary distribution (seeSection 2.2, “Installing MySQL on Unix/Linux Using Generic Binaries”), except that it is used on all platforms and includes steps to configure and compile the distribution. For example, with a compressedtar file source distribution on Unix, the basic installation command sequence looks like this:

# Preconfiguration setup$> groupadd mysql$> useradd -r -g mysql -s /bin/false mysql# Beginning of source-build specific instructions$> tar zxvf mysql-VERSION.tar.gz$> cd mysql-VERSION$> mkdir bld$> cd bld$> cmake ..$> make$> make install# End of source-build specific instructions# Postinstallation setup$> cd /usr/local/mysql$> mkdir mysql-files$> chown mysql:mysql mysql-files$> chmod 750 mysql-files$> bin/mysqld --initialize --user=mysql$> bin/mysql_ssl_rsa_setup$> bin/mysqld_safe --user=mysql &# Next command is optional$> cp support-files/mysql.server /etc/init.d/mysql.server

A more detailed version of the source-build specific instructions is shown following.

Note

The procedure shown here does not set up any passwords for MySQL accounts. After following the procedure, proceed toSection 2.9, “Postinstallation Setup and Testing”, for postinstallation setup and testing.

Perform Preconfiguration Setup

On Unix, set up themysql user that owns the database directory and that should be used to run and execute the MySQL server, and the group to which this user belongs. For details, seeCreate a mysql User and Group. Then perform the following steps as themysql user, except as noted.

Obtain and Unpack the Distribution

Pick the directory under which you want to unpack the distribution and change location into it.

Obtain a distribution file using the instructions inSection 2.1.3, “How to Get MySQL”.

Unpack the distribution into the current directory:

  • To unpack a compressedtar file,tar can decompress and unpack the distribution if it hasz option support:

    $> tar zxvf mysql-VERSION.tar.gz

    If yourtar does not havez option support, usegunzip to decompress the distribution andtar to unpack it:

    $> gunzip < mysql-VERSION.tar.gz | tar xvf -

    Alternatively,CMake can decompress and unpack the distribution:

    $> cmake -E tar zxvf mysql-VERSION.tar.gz
  • To unpack a Zip archive, useWinZip or another tool that can read.zip files.

Unpacking the distribution file creates a directory namedmysql-VERSION.

Configure the Distribution

Change location into the top-level directory of the unpacked distribution:

$> cd mysql-VERSION

Build outside of the source tree to keep the tree clean. If the top-level source directory is namedmysql-src under your current working directory, you can build in a directory namedbuild at the same level. Create the directory and go there:

$> mkdir bld$> cd bld

Configure the build directory. The minimum configuration command includes no options to override configuration defaults:

$> cmake ../mysql-src

The build directory need not be outside the source tree. For example, you can build in a directory namedbuild under the top-level source tree. To do this, starting withmysql-src as your current working directory, create the directorybuild and then go there:

$> mkdir build$> cd build

Configure the build directory. The minimum configuration command includes no options to override configuration defaults:

$> cmake ..

If you have multiple source trees at the same level (for example, to build multiple versions of MySQL), the second strategy can be advantageous. The first strategy places all build directories at the same level, which requires that you choose a unique name for each. With the second strategy, you can use the same name for the build directory within each source tree. The following instructions assume this second strategy.

On Windows, specify the development environment. For example, the following commands configure MySQL for 32-bit or 64-bit builds, respectively:

$> cmake .. -G "Visual Studio 12 2013"$> cmake .. -G "Visual Studio 12 2013 Win64"

On macOS, to use the Xcode IDE:

$> cmake .. -G Xcode

When you runCmake, you might want to add options to the command line. Here are some examples:

For a more extensive list of options, seeSection 2.8.7, “MySQL Source-Configuration Options”.

To list the configuration options, use one of the following commands:

$> cmake .. -L   # overview$> cmake .. -LH  # overview with help text$> cmake .. -LAH # all params with help text$> ccmake ..     # interactive display

IfCMake fails, you might need to reconfigure by running it again with different options. If you do reconfigure, take note of the following:

  • IfCMake is run after it has previously been run, it may use information that was gathered during its previous invocation. This information is stored inCMakeCache.txt. WhenCMake starts, it looks for that file and reads its contents if it exists, on the assumption that the information is still correct. That assumption is invalid when you reconfigure.

  • Each time you runCMake, you must runmake again to recompile. However, you may want to remove old object files from previous builds first because they were compiled using different configuration options.

To prevent old object files or configuration information from being used, run these commands in the build directory on Unix before re-runningCMake:

$> make clean$> rm CMakeCache.txt

Or, on Windows:

$> devenv MySQL.sln /clean$> del CMakeCache.txt

Before asking on theMySQL Community Slack, check the files in theCMakeFiles directory for useful information about the failure. To file a bug report, please use the instructions inSection 1.5, “How to Report Bugs or Problems”.

Build the Distribution

On Unix:

$> make$> make VERBOSE=1

The second command setsVERBOSE to show the commands for each compiled source.

Usegmake instead on systems where you are using GNUmake and it has been installed asgmake.

On Windows:

$> devenv MySQL.sln /build RelWithDebInfo

If you have gotten to the compilation stage, but the distribution does not build, seeSection 2.8.8, “Dealing with Problems Compiling MySQL”, for help. If that does not solve the problem, please enter it into our bugs database using the instructions given inSection 1.5, “How to Report Bugs or Problems”. If you have installed the latest versions of the required tools, and they crash trying to process our configuration files, please report that also. However, if you get acommand not found error or a similar problem for required tools, do not report it. Instead, make sure that all the required tools are installed and that yourPATH variable is set correctly so that your shell can find them.

Install the Distribution

On Unix:

$> make install

This installs the files under the configured installation directory (by default,/usr/local/mysql). You might need to run the command asroot.

To install in a specific directory, add aDESTDIR parameter to the command line:

$> make install DESTDIR="/opt/mysql"

Alternatively, generate installation package files that you can install where you like:

$> make package

This operation produces one or more.tar.gz files that can be installed like generic binary distribution packages. SeeSection 2.2, “Installing MySQL on Unix/Linux Using Generic Binaries”. If you runCMake with-DCPACK_MONOLITHIC_INSTALL=1, the operation produces a single file. Otherwise, it produces multiple files.

On Windows, generate the data directory, then create a.zip archive installation package:

$> devenv MySQL.sln /build RelWithDebInfo /project initial_database$> devenv MySQL.sln /build RelWithDebInfo /project package

You can install the resulting.zip archive where you like. SeeSection 2.3.4, “Installing MySQL on Microsoft Windows Using anoinstall ZIP Archive”.

Perform Postinstallation Setup

The remainder of the installation process involves setting up the configuration file, creating the core databases, and starting the MySQL server. For instructions, seeSection 2.9, “Postinstallation Setup and Testing”.

Note

The accounts that are listed in the MySQL grant tables initially have no passwords. After starting the server, you should set up passwords for them using the instructions inSection 2.9, “Postinstallation Setup and Testing”.