Chinaunix首页 | 论坛 | 博客
  • 博客访问: 193494
  • 博文数量: 53
  • 博客积分: 2059
  • 博客等级: 大尉
  • 技术积分: 577
  • 用 户 组: 普通用户
  • 注册时间: 2010-03-30 03:03
文章分类
文章存档

2012年(4)

2011年(19)

2010年(30)

分类: Mysql/postgreSQL

2011-05-06 13:34:55

2.9. Installing MySQL from Source

   Building MySQL from the source code enables you to customize build
   parameters, compiler optimizations, and installation location. For
   a list of systems on which MySQL is known to run, see Section
   2.1.1, "Operating Systems Supported by MySQL Community Server."

   Before you proceed with an installation from source, check whether
   Oracle produces a precompiled binary distribution for your
   platform and whether it works for you. We put a great deal of
   effort into ensuring that our binaries are built with the best
   possible options for optimal performance. Instructions for
   installing binary distributions are available in Section 2.2,
   "Installing MySQL from Generic Binaries on Unix/Linux."

Source Installation Methods

   There are two methods for installing MySQL from source:

     * Use a standard MySQL source distribution. To obtain a standard
       distribution, see Section 2.1.3, "How to Get MySQL." For
       instructions on building from a standard distribution, see
       Section 2.9.2, "Installing MySQL from a Standard Source
       Distribution."
       Standard distributions are available as compressed tar files,
       Zip archives, or RPM packages. Distribution files have names
       of the form mysql-VERSION.tar.gz, mysql-VERSION.zip, or
       mysql-VERSION.rpm, where VERSION is a number like 5.6.3. File
       names for source distributions can be distinguished from those
       for precompiled binary distributions in that source
       distribution names are generic and include no platform name,
       whereas binary distribution names include a platform name
       indicating the type of system for which the distribution is
       intended (for example, pc-linux-i686 or winx64).

     * Use a MySQL development tree. Development trees have not
       necessarily received the same level of testing as standard
       release distributions, so this installation method is usually
       required only if you need the most recent code changes. For
       information on building from one of the development trees, see
       Section 2.9.3, "Installing MySQL from a Development Source
       Tree."

Source Installation System Requirements

   Installation of MySQL from source requires several development
   tools. Some of these tools are needed no matter whether you use a
   standard source distribution or a development source tree. Other
   tool requirements depend on which installation method you use.

   To install MySQL from source, your system must have the following
   tools, regardless of installation method:

     * CMake, which is used as the build framework on all platforms.
       CMake can be downloaded from

     * A good make program. Although some platforms come with their
       own make implementations, it is highly recommended that you
       use GNU make 3.75 or newer. It may already be available on
       your system as gmake. GNU make is available from
      

     * A working ANSI C++ compiler. GCC 3.2 or later, Sun Studio 10
       or later, Visual Studio 2008 or later, and many current
       vendor-supplied compilers are known to work.

     * Perl is needed if you intend to run test scripts. Most
       Unix-like systems include Perl. On Windows, you can use a
       version such as ActiveState Perl.

   To install MySQL from a standard source distribution, one of the
   following tools is required to unpack the distribution file:

     * For a .tar.gz compressed tar file: GNU gunzip to uncompress
       the distribution and a reasonable tar to unpack it. If your
       tar program supports the z option, it can both uncompress and
       unpack the file.
       GNU tar is known to work. The standard tar provided with some
       operating systems is not able to unpack the long file names in
       the MySQL distribution. You should download and install GNU
       tar, or if available, use a preinstalled version of GNU tar.
       Usually this is available as gnutar, gtar, or as tar within a
       GNU or Free Software directory, such as /usr/sfw/bin or
       /usr/local/bin. GNU tar is available from
      

     * For a .zip Zip archive: WinZip or another tool that can read
       .zip files.

     * For an .rpm RPM package: The rpmbuild program used to build
       the distribution unpacks it.

   To install MySQL from a development source tree, the following
   additional tools are required:

     * To obtain the source tree, you must have Bazaar installed. The
       Bazaar VCS Web site () has instructions
       for downloading and installing Bazaar on different platforms.
       Bazaar is supported on any platform that supports Python, and
       is therefore compatible with any Linux, Unix, Windows, or Mac
       OS X host.

     * bison is needed to generate sql_yacc.cc from sql_yacc.yy You
       should use the latest version of bison where possible.
       Versions 1.75 and 2.1 are known to work. There have been
       reported problems with bison 1.875. If you experience
       problems, upgrade to a later, rather than earlier, version.
       bison is available from
       bison for Windows can be downloaded from
       Download
       the package labeled "Complete package, excluding sources". On
       Windows, the default location for bison is the C:\Program
       Files\GnuWin32 directory. Some utilities may fail to find
       bison because of the space in the directory name. Also, Visual
       Studio may simply hang if there are spaces in the path. You
       can resolve these problems by installing into a directory that
       does not contain a space; for example C:\GnuWin32.

     * On OpenSolaris and Solaris Express, m4 must be installed in
       addition to bison. m4 is available from
      

   Note

   If you have to install any programs, modify your PATH environment
   variable to include any directories in which the programs are
   located. See Section 4.2.4, "Setting Environment Variables."

   If you run into problems and need to file a bug report, please use
   the instructions in Section 1.7, "How to Report Bugs or Problems."

2.9.1. MySQL Layout for Source Installation

   By default, when you install MySQL after compiling it from source,
   the installation step installs files under /usr/local/mysql. The
   component locations under the installation directory are the same
   as for binary distributions. See Section 2.2, "MySQL Installation
   Layout for Generic Unix/Linux Binary Package," and Section 2.3.1,
   "MySQL Installation Layout on Microsoft Windows." To configure
   installation locations different from the defaults, use the
   options described at Section 2.9.4, "MySQL Source-Configuration
   Options."

2.9.2. Installing MySQL from a Standard Source Distribution

   To install MySQL from a standard source distribution:

    1. Verify that your system satisfies the tool requirements listed
       at Section 2.9, "Installing MySQL from Source."

    2. Obtain a distribution file using the instructions in Section
       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 in
       Section 2.10, "Postinstallation Setup and Testing."

   In MySQL 5.6, CMake is used as the build framework on all
   platforms. The instructions given here should enable you to
   produce a working installation. For additional information on
   using CMake to build MySQL, see

   If you start from a source RPM, use the following command to make
   a binary RPM that you can install. If you do not have rpmbuild,
   use rpm instead.
shell> rpmbuild --rebuild --clean MySQL-VERSION.src.rpm

   The result is one or more binary RPM packages that you install as
   indicated in Section 2.5.1, "Installing MySQL from RPM Packages on
   Linux."

   The sequence for installation from a compressed tar file or Zip
   archive source distribution is similar to the process for
   installing from a generic binary distribution (see Section 2.2,
   "Installing MySQL from Generic Binaries on Unix/Linux"), except
   that it is used on all platforms and includes steps to configure
   and compile the distribution. For example, with a compressed tar
   file source distribution on Unix, the basic installation command
   sequence looks like this:
# Preconfiguration setup
shell> groupadd mysql
shell> useradd -r -g mysql mysql
# Beginning of source-build specific instructions
shell> tar zxvf mysql-VERSION.tar.gz
shell> cd mysql-VERSION
shell> cmake .
shell> make
shell> make install
# End of source-build specific instructions
# Postinstallation setup
shell> cd /usr/local/mysql
shell> chown -R mysql .
shell> chgrp -R mysql .
shell> scripts/mysql_install_db --user=mysql
shell> chown -R root .
shell> chown -R mysql data
# Next command is optional
shell> cp support-files/my-medium.cnf /etc/my.cnf
shell> bin/mysqld_safe --user=mysql &
# Next command is optional
shell> 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 to Section 2.10,
   "Postinstallation Setup and Testing," for postinstallation setup
   and testing.

Perform Preconfiguration Setup

   On Unix, set up the mysql user and group that will be used to run
   and execute the MySQL server and own the database directory. For
   details, see Creating a mysql System User and Group, in Section
   2.2, "Installing MySQL from Generic Binaries on Unix/Linux." Then
   perform the following steps as the mysql 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 in Section
   2.1.3, "How to Get MySQL."

   Unpack the distribution into the current directory:

     * To unpack a compressed tar file, tar can uncompress and unpack
       the distribution if it has z option support:
shell> tar zxvf mysql-VERSION.tar.gz
       If your tar does not have z option support, use gunzip to
       unpack the distribution and tar to unpack it:
shell> gunzip < mysql-VERSION.tar.gz | tar xvf -
       Alternatively, CMake can uncompress and unpack the
       distribution:
shell> cmake -E tar zxvf mysql-VERSION.tar.gz

     * To unpack a Zip archive, use WinZip or another tool that can
       read .zip files.

   Unpacking the distribution file creates a directory named
   mysql-VERSION.

Configure the Distribution

   Change location into the top-level directory of the unpacked
   distribution:
shell> cd mysql-VERSION

   Configure the source directory. The minimum configuration command
   includes no options to override configuration defaults:
shell> cmake .

   On Windows, specify the development environment. For example, the
   following commands configure MySQL for 32-bit or 64-bit builds,
   respectively:
shell> cmake . -G "Visual Studio 9 2008"
shell> cmake . -G "Visual Studio 9 2008 Win64"

   On Mac OS X, to use the Xcode IDE:
shell> cmake . -G Xcode

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

     * -DBUILD_CONFIG=mysql_release: Configure the source with the
       same build options used by Oracle to produce binary
       distributions for official MySQL releases.

     * -DCMAKE_INSTALL_PREFIX=dir_name: Configure the distribution
       for installation under a particular location.

     * -DCPACK_MONOLITHIC_INSTALL=1: Cause make package to generate a
       single installation file rather than multiple files.

     * -DWITH_DEBUG=1: Build the distribution with debugging support.

   For a more extensive list of options, see Section 2.9.4, "MySQL
   Source-Configuration Options."

   To list the configuration options, use one of the following
   commands:
shell> cmake . -L   # overview
shell> cmake . -LH  # overview with help text
shell> cmake . -LAH # all params with help text
shell> ccmake .     # interactive display

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

     * If CMake is run after it has previously been run, it may use
       information that was gathered during its previous invocation.
       This information is stored in CMakeCache.txt. When CMake
       starts up, 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 run CMake, you must run make 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 on Unix before re-running CMake:
shell> make clean
shell> rm CMakeCache.txt

   Or, on Windows:
shell> devenv MySQL.sln /clean
shell> del CMakeCache.txt

   If you build out of the source tree (as described later), the
   CMakeCache.txt file and all built files are in the build
   directory, so you can remove that directory to object files and
   cached configuration information.

   If you are going to send mail to a MySQL mailing list to ask for
   configuration assistance, first check the files in the CMakeFiles
   directory for useful information about the failure. To file a bug
   report, please use the instructions in Section 1.7, "How to Report
   Bugs or Problems."

Build the Distribution

   On Unix:
shell> make
shell> make VERBOSE=1

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

   Use gmake instead on systems where you are using GNU make and it
   has been installed as gmake.

   On Windows:
shell> devenv MySQL.sln /build RelWithDebInfo

   It is possible to build out of the source tree to keep the tree
   clean. If the top-level source directory is named mysql-src under
   your current working directory, you can build in a directory named
   build at the same level like this:
shell> mkdir build
shell> cd build
shell> cmake ../mysql-src

   If you have gotten to the compilation stage, but the distribution
   does not build, see Section 2.9.5, "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 in Section 1.7, "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 a command 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 your
   PATH variable is set correctly so that your shell can find them.

Install the Distribution

   On Unix:
shell> make install

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

   To install in a specific directory, add a DESTDIR parameter to the
   command line:
shell> make install DESTDIR="/opt/mysql"

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

   This operation produces one or more .tar.gz files that can be
   installed like generic binary distribution packages. See Section
   2.2, "Installing MySQL from Generic Binaries on Unix/Linux." If
   you run CMake 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:
shell> devenv MySQL.sln /build RelWithDebInfo /project initial_databa
se
shell> devenv MySQL.sln /build RelWithDebInfo /project package

   You can install the resulting .zip archive where you like. See
   Section 2.3.5, "Installing MySQL on Microsoft Windows Using a
   noinstall 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, see Section 2.10,
   "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 in Section 2.10,
   "Postinstallation Setup and Testing."

2.9.3. Installing MySQL from a Development Source Tree

   This section discusses how to install MySQL from the latest
   development source code. Development trees have not necessarily
   received the same level of testing as standard release
   distributions, so this installation method is usually required
   only if you need the most recent code changes. Do not use a
   development tree for production systems. If your goal is simply to
   get MySQL up and running on your system, you should use a standard
   release distribution (either a binary or source distribution). See
   Section 2.1.3, "How to Get MySQL."

   MySQL development projects are hosted on Launchpad
   (). MySQL projects, including MySQL Server,
   MySQL Workbench, and others are available from the Oracle/MySQL
   Engineering (~mysql) page. For the
   repositories related only to MySQL Server, see the MySQL Server
   (mysql-server) page.

   To install MySQL from a development source tree, your system must
   satisfy the tool requirements listed at Section 2.9, "Installing
   MySQL from Source," including the requirements for Bazaar and
   bison. For information about using Bazaar with MySQL, see
  

   To create a local branch of the MySQL development tree 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.6 mysql-5.6
       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.

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

    4. 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.6 mysql-5.6-build

    5. 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
       (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." If you
       think you have a better idea on how to do something, send an
       email message to the list with a patch.

   After you have the local branch, you can build MySQL server from
   the source code. For information, see Section 2.9.2, "Installing
   MySQL from 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.6, "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 22.1.2,
   "The MySQL Test Suite."

2.9.4. MySQL Source-Configuration Options

   The CMake program provides a great deal of control over how you
   configure a MySQL source distribution. Typically, you do this
   using options on the CMake command line. For information about
   options supported by CMake, run either of these commands in the
   top-level source directory:
shell> cmake . -LH
shell> ccmake .

   You can also affect CMake using certain environment variables. See
   Section 2.12, "Environment Variables."

   The following table shows the available CMake options. In the
   Default column, PREFIX stands for the value of the
   CMAKE_INSTALL_PREFIX option, which specifies the installation base
   directory. This value is used as the parent location for several
   of the installation subdirectories.

   Table 2.14. MySQL Source-Configuration Option Reference (CMake)
   Formats Description Default Introduced Removed
   BUILD_CONFIG Use same build options as official releases
   CMAKE_BUILD_TYPE Type of build to produce RelWithDebInfo
   CMAKE_INSTALL_PREFIX Installation base directory /usr/local/mysql

   CPACK_MONOLITHIC_INSTALL Whether package build produces single
   file OFF
   DEFAULT_CHARSET The default server character set latin1
   DEFAULT_COLLATION The default server collation latin1_swedish_ci

   ENABLE_DEBUG_SYNC Whether to enable Debug Sync support ON
   ENABLE_DOWNLOADS Whether to download optional files OFF
   ENABLE_DTRACE Whether to include DTrace support
   ENABLED_LOCAL_INFILE Whether to enable LOCAL for LOAD DATA INFILE
   OFF
   ENABLED_PROFILING Whether to enable query profiling code ON
   INSTALL_BINDIR User executables directory PREFIX/bin
   INSTALL_DOCDIR Documentation directory PREFIX/docs
   INSTALL_DOCREADMEDIR README file directory PREFIX
   INSTALL_INCLUDEDIR Header file directory PREFIX/include
   INSTALL_INFODIR Info file directory PREFIX/docs
   INSTALL_LAYOUT Select predefined installation layout STANDALONE

   INSTALL_LIBDIR Library file directory PREFIX/lib
   INSTALL_MANDIR Manual page directory PREFIX/man
   INSTALL_MYSQLSHAREDIR Shared data directory PREFIX/share
   INSTALL_MYSQLTESTDIR mysql-test directory PREFIX/mysql-test
   INSTALL_PLUGINDIR Plugin directory PREFIX/lib/plugin
   INSTALL_SBINDIR Server executable directory PREFIX/bin
   INSTALL_SCRIPTDIR Scripts directory PREFIX/scripts
   INSTALL_SHAREDIR aclocal/mysql.m4 installation directory
   PREFIX/share
   INSTALL_SQLBENCHDIR sql-bench directory PREFIX
   INSTALL_SUPPORTFILESDIR Extra support files directory
   PREFIX/support-files
   MYSQL_DATADIR Data directory
   MYSQL_MAINTAINER_MODE Whether to enable MySQL maintainer-specific
   development environment OFF
   MYSQL_TCP_PORT TCP/IP port number 3306
   MYSQL_UNIX_ADDR Unix socket file /tmp/mysql.sock
   SYSCONFDIR Option file directory
   WITH_COMMENT Comment about compilation environment
   WITH_DEBUG Whether to include debugging support OFF
   WITH_EMBEDDED_SERVER Whether to build embedded server OFF
   WITH_xxx_STORAGE_ENGINE Compile storage engine xxx statically into
   server
   WITH_EXTRA_CHARSETS Which extra character sets to include all
   WITH_LIBWRAP Whether to include libwrap (TCP wrappers) support OFF

   WITH_READLINE Use bundled readline OFF
   WITH_SSL Type of SSL support no
   WITH_ZLIB Type of zlib support system
   WITHOUT_xxx_STORAGE_ENGINE Exclude storage engine xxx from build

   The following sections provide more information about CMake
   options.

     * General Options

     * Installation Layout Options

     * Feature Options

     * Compiler Flags

   For boolean options, the value may be specified as 1 or ON to
   enable the option, or as 0 or OFF to disable the option.

   Many options configure compile-time defaults that can be
   overridden at server startup. For example, the
   CMAKE_INSTALL_PREFIX, MYSQL_TCP_PORT, and MYSQL_UNIX_ADDR options
   that configure the default installation base directory location,
   TCP/IP port number, and Unix socket file can be changed at server
   startup with the --basedir, --port, and --socket options for
   mysqld. Where applicable, configuration option descriptions
   indicate the corresponding mysqld startup option.

General Options


     * -DBUILD_CONFIG=mysql_release
       This option configures a source distribution with the same
       build options used by Oracle to produce binary distributions
       for official MySQL releases.

     * -DCMAKE_BUILD_TYPE=type
       The type of build to produce:

          + RelWithDebInfo: Enable optimizations and generate
            debugging information. This is the default MySQL build
            type.

          + Debug: Disable optimizations and generate debugging
            information. This build type is also used if the
            WITH_DEBUG option is enabled. That is, -DWITH_DEBUG=1 has
            the same effect as -DCMAKE_BUILD_TYPE=Debug.

     * -DCPACK_MONOLITHIC_INSTALL=bool
       This option affects whether the make package operation
       produces multiple installation package files or a single file.
       If disabled, the operation produces multiple installation
       package files, which may be useful if you want to install only
       a subset of a full MySQL installation. If enabled, it produces
       a single file for installing everything.

Installation Layout Options

   The CMAKE_INSTALL_PREFIX option indicates the base installation
   directory. Other options with names of the form INSTALL_xxx that
   indicate component locations are interpreted relative to the
   prefix and their values are relative pathnames. Their values
   should not include the prefix.

     * -DCMAKE_INSTALL_PREFIX=dir_name
       The installation base directory.
       This value can be set at server startup with the --basedir
       option.

     * -DINSTALL_BINDIR=dir_name
       Where to install user programs.

     * -DINSTALL_DOCDIR=dir_name
       Where to install documentation.

     * -DINSTALL_DOCREADMEDIR=dir_name
       Where to install README files.

     * -DINSTALL_INCLUDEDIR=dir_name
       Where to install header files.

     * -DINSTALL_INFODIR=dir_name
       Where to install Info files.

     * -DINSTALL_LAYOUT=name
       Select a predefined installation layout:

          + STANDALONE: Same layout as used for .tar.gz and .zip
            packages. This is the default.

          + RPM: Layout similar to RPM packages.

          + SVR4: Solaris package layout.

          + DEB: DEB package layout (experimental).
       You can select a predefined layout but modify individual
       component installation locations by specifying other options.
       For example:
shell> cmake . -DINSTALL_LAYOUT=SVR4 -DMYSQL_DATADIR=/var/mysql/data

     * -DINSTALL_LIBDIR=dir_name
       Where to install library files.

     * -DINSTALL_MANDIR=dir_name
       Where to install manual pages.

     * -DINSTALL_MYSQLSHAREDIR=dir_name
       Where to install shared data files.

     * -DINSTALL_MYSQLTESTDIR=dir_name
       Where to install the mysql-test directory.

     * -DINSTALL_PLUGINDIR=dir_name
       The location of the plugin directory.
       This value can be set at server startup with the --plugin_dir
       option.

     * -DINSTALL_SBINDIR=dir_name
       Where to install the mysqld server.

     * -DINSTALL_SCRIPTDIR=dir_name
       Where to install mysql_install_db.

     * -DINSTALL_SHAREDIR=dir_name
       Where to install aclocal/mysql.m4.

     * -DINSTALL_SQLBENCHDIR=dir_name
       Where to install the sql-bench directory. To not install this
       directory, use an empty value (-DINSTALL_SQLBENCHDIR=).

     * -DINSTALL_SUPPORTFILESDIR=dir_name
       Where to install extra support files.

     * -DMYSQL_DATADIR=dir_name
       The location of the MySQL data directory.
       This value can be set at server startup with the --datadir
       option.

     * -DSYSCONFDIR=dir_name
       The default my.cnf option file directory.
       This location cannot be set at server startup, but you can
       start the server with a given option file using the
       --defaults-file=file_name option, where file_name is the full
       path name to the file.

Storage Engine Options

   Storage engines are built as plugins. You can build a plugin as a
   static module (compiled into the server) or a dynamic module
   (built as a dynamic library that must be installed into the server
   using the INSTALL PLUGIN statement or the --plugin-load option
   before it can be used). Some plugins might not support static or
   dynamic building.

   The MyISAM, MERGE, MEMORY, and CSV engines are mandatory (always
   compiled into the server) and need not be installed explicitly.

   To compile a storage engine statically into the server, use
   -DWITH_engine_STORAGE_ENGINE=1. Some permissible engine values are
   ARCHIVE, BLACKHOLE, EXAMPLE, FEDERATED, INNOBASE (InnoDB),
   PARTITION (partitioning support), and PERFSCHEMA (Performance
   Schema). Examples:
-DWITH_INNOBASE_STORAGE_ENGINE=1
-DWITH_ARCHIVE_STORAGE_ENGINE=1
-DWITH_BLACKHOLE_STORAGE_ENGINE=1
-DWITH_PERFSCHEMA_STORAGE_ENGINE=1

   To exclude a storage engine from the build, use
   -DWITHOUT_engine_STORAGE_ENGINE=1. Examples:
-DWITHOUT_EXAMPLE_STORAGE_ENGINE=1
-DWITHOUT_FEDERATED_STORAGE_ENGINE=1
-DWITHOUT_PARTITION_STORAGE_ENGINE=1

   If neither -DWITH_engine_STORAGE_ENGINE nor
   -DWITHOUT_engine_STORAGE_ENGINE are specified for a given storage
   engine, the engine is built as a shared module, or excluded if it
   cannot be built as a shared module.

Feature Options


     * -DDEFAULT_CHARSET=charset_name
       The server character set. By default, MySQL uses the latin1
       (cp1252 West European) character set.
       charset_name may be one of binary, armscii8, ascii, big5,
       cp1250, cp1251, cp1256, cp1257, cp850, cp852, cp866, cp932,
       dec8, eucjpms, euckr, gb2312, gbk, geostd8, greek, hebrew,
       hp8, keybcs2, koi8r, koi8u, latin1, latin2, latin5, latin7,
       macce, macroman, sjis, swe7, tis620, ucs2, ujis, utf8,
       utf8mb4, utf16, utf16le, utf32. The permissible character sets
       are listed in the cmake/character_sets.cmake file as the value
       of CHARSETS_AVAILABLE.
       This value can be set at server startup with the
       --character_set_server option.

     * -DDEFAULT_COLLATION=collation_name
       The server collation. By default, MySQL uses
       latin1_swedish_ci. Use the SHOW COLLATION statement to
       determine which collations are available for each character
       set.
       This value can be set at server startup with the
       --collation_server option.

     * -DENABLE_DEBUG_SYNC=bool
       Whether to compile the Debug Sync facility into the server.
       This facility is used for testing and debugging. This option
       is enabled by default, but has no effect unless MySQL is
       configured with debugging enabled. If debugging is enabled and
       you want to disable Debug Sync, use -DENABLE_DEBUG_SYNC=0.
       When compiled in, Debug Sync is disabled by default at
       runtime. To enable it, start mysqld with the
       --debug-sync-timeout=N option, where N is a timeout value
       greater than 0. (The default value is 0, which disables Debug
       Sync.) N becomes the default timeout for individual
       synchronization points.
       For a description of the Debug Sync facility and how to use
       synchronization points, see MySQL Internals: Test
       Synchronization
       (
       ion).

     * -DENABLE_DOWNLOADS=bool
       Whether to download optional files. For example, with this
       option enabled, CMake downloads the Google Test distribution
       that is used by the test suite to run unit tests.

     * -DENABLE_DTRACE=bool
       Whether to include support for DTrace probes. For information
       about DTrace, wee Section 5.7, "Tracing mysqld Using DTrace"

     * -DENABLED_LOCAL_INFILE=bool
       Whether to enable LOCAL capability in the client library for
       LOAD DATA INFILE.
       This option controls client-side LOCAL capability, but the
       capability can be set on the server side at server startup
       with the --local-infile option. See Section 5.3.5, "Security
       Issues with LOAD DATA LOCAL."

     * -DENABLED_PROFILING=bool
       Whether to enable query profiling code (for the SHOW PROFILE
       and SHOW PROFILES statements).

     * -DMYSQL_MAINTAINER_MODE=bool
       Whether to enable a MySQL maintainer-specific development
       environment. If enabled, this option causes compiler warnings
       to become errors.

     * -DMYSQL_TCP_PORT=port_num
       The port number on on which the server listens for TCP/IP
       connections. The default is 3306.
       This value can be set at server startup with the --port
       option.

     * -DMYSQL_UNIX_ADDR=file_name
       The Unix socket file path on which the server listens for
       socket connections. This must be an absolute path name. The
       default is /tmp/mysql.sock.
       This value can be set at server startup with the --socket
       option.

     * -DWITH_COMMENT=string
       A descriptive comment about the compilation environment.

     * -DWITH_DEBUG=bool
       Whether to include debugging support.
       Configuring MySQL with debugging support enables you to use
       the --debug="d,parser_debug" option when you start the server.
       This causes the Bison parser that is used to process SQL
       statements to dump a parser trace to the server's standard
       error output. Typically, this output is written to the error
       log.

     * -DWITH_EMBEDDED_SERVER=bool
       Whether to build the libmysqld embedded server library.

     * -DWITH_EXTRA_CHARSETS=name
       Which extra character sets to include:

          + all: All character sets. This is the default.

          + complex: Complex character sets.

          + none: No extra character sets.

     * -DWITH_LIBWRAP=bool
       Whether to include libwrap (TCP wrappers) support.

     * -DWITH_READLINE=bool
       Whether to use the readline library bundled with the
       distribution.

     * -DWITH_SSL=ssl_type
       The type of SSL support to include, if any:

          + no: No SSL support. This is the default.

          + yes: Use the system SSL library if present, else the
            library bundled with the distribution.

          + bundled: Use the SSL library bundled with the
            distribution.

          + system: Use the system SSL library.
       For information about using SSL support, see Section 5.5.8,
       "Using SSL for Secure Connections."

     * -DWITH_ZLIB=zlib_type
       Some features require that the server be built with
       compression library support, such as the COMPRESS() and
       UNCOMPRESS() functions, and compression of the client/server
       protocol. The WITH_ZLIB indicates the source of zlib support:

          + bundled: Use the zlib library bundled with the
            distribution.

          + system: Use the system zlib library. This is the default.

Compiler Flags

   To specify compiler flags, set the CFLAGS and CXXFLAGS environment
   variables before running CMake. Example:
shell> CFLAGS=-DDISABLE_GRANT_OPTIONS
shell> CXXFLAGS=-DDISABLE_GRANT_OPTIONS
shell> export CFLAGS CXXFLAGS
shell> cmake [options]

   The following flags control configuration features:

     * DISABLE_GRANT_OPTIONS
       If this flag is defined, it causes the --bootstrap,
       --skip-grant-tables, and --init-file options for mysqld to be
       disabled.

     * HAVE_EMBEDDED_PRIVILEGE_CONTROL
       By default, authentication for connections to the embedded
       server is disabled. To enable connection authentication,
       define this flag.

2.9.5. Dealing with Problems Compiling MySQL

   The solution to many problems involves reconfiguring. If you do
   reconfigure, take note of the following:

     * If CMake is run after it has previously been run, it may use
       information that was gathered during its previous invocation.
       This information is stored in CMakeCache.txt. When CMake
       starts up, 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 run CMake, you must run make 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 on Unix before re-running CMake:
shell> make clean
shell> rm CMakeCache.txt

   Or, on Windows:
shell> devenv MySQL.sln /clean
shell> del CMakeCache.txt

   On some systems, warnings may occur due to differences in system
   include files. The following list describes other problems that
   have been found to occur most often when compiling MySQL:

     * To define flags to be used by your C or C++ compilers, specify
       them using the CFLAGS and CXXFLAGS environment variables. You
       can also specify the compiler names this way using CC and CXX.
       For example:
shell> CC=gcc
shell> CFLAGS=-O3
shell> CXX=gcc
shell> CXXFLAGS=-O3
shell> export CC CFLAGS CXX CXXFLAGS

     * If compilation fails, check whether the MYSQL_MAINTAINER_MODE
       option is enabled. This mode causes compiler warnings to
       become errors, so disabling it may enable compilation to
       proceed.

     * If your compile fails with errors such as any of the
       following, you must upgrade your version of make to GNU make:
make: Fatal error in reader: Makefile, line 18:
Badly formed macro assignment
       Or:
make: file `Makefile' line 18: Must be a separator (:
       Or:
pthread.h: No such file or directory
       Solaris and FreeBSD are known to have troublesome make
       programs.
       GNU make 3.75 is known to work.

     * The sql_yacc.cc file is generated from sql_yacc.yy. Normally,
       the build process does not need to create sql_yacc.cc because
       MySQL comes with a pregenerated copy. However, if you do need
       to re-create it, you might encounter this error:
"sql_yacc.yy", line xxx fatal: default action causes potential...
       This is a sign that your version of yacc is deficient. You
       probably need to install bison (the GNU version of yacc) and
       use that instead.
       Versions of bison older than 1.75 may report this error:
sql_yacc.yy:#####: fatal error: maximum table size (32767) exceeded
       The maximum table size is not actually exceeded; the error is
       caused by bugs in older versions of bison.

     * On Debian Linux 3.0, you need to install gawk instead of the
       default mawk.

   For information about acquiring or updating tools, see the system
   requirements in Section 2.9, "Installing MySQL from Source."

2.9.6. MySQL Configuration and Third-Party Tools

   Third-party tools that need to determine the MySQL version from
   the MySQL source can read the VERSION file in the top-level source
   directory. The file lists the pieces of the version separately.
   For example, if the version is 5.5.8, the file looks like this:
MYSQL_VERSION_MAJOR=5
MYSQL_VERSION_MINOR=5
MYSQL_VERSION_PATCH=8
MYSQL_VERSION_EXTRA=

   If the source is not for a General Availablility (GA) release, the
   MYSQL_VERSION_EXTRA value will be nonempty. For example, the value
   for a Release Candidate release would look like this:
MYSQL_VERSION_EXTRA=rc

   To construct a five-digit number from the version components, use
   this formula:
MYSQL_VERSION_MAJOR*10000 + MYSQL_VERSION_MINOR*100 + MYSQL_VERSION_P
ATCH

2.10. Postinstallation Setup and Testing

   After installing MySQL, there are some issues that you should
   address. For example, on Unix, you should initialize the data
   directory and create the MySQL grant tables. On all platforms, an
   important security concern is that the initial accounts in the
   grant tables have no passwords. You should assign passwords to
   prevent unauthorized access to the MySQL server. Optionally, you
   can create time zone tables to enable recognition of named time
   zones.

   The following sections include postinstallation procedures that
   are specific to Windows systems and to Unix systems. Another
   section, Section 2.10.1.3, "Starting and Troubleshooting the MySQL
   Server," applies to all platforms; it describes what to do if you
   have trouble getting the server to start. Section 2.10.2,
   "Securing the Initial MySQL Accounts," also applies to all
   platforms. You should follow its instructions to make sure that
   you have properly protected your MySQL accounts by assigning
   passwords to them.

   When you are ready to create additional user accounts, you can
   find information on the MySQL access control system and account
   management in Section 5.4, "The MySQL Access Privilege System,"
   and Section 5.5, "MySQL User Account Management."

2.10.1. Unix Postinstallation Procedures

   After installing MySQL on Unix, you must initialize the grant
   tables, start the server, and make sure that the server works
   satisfactorily. You may also wish to arrange for the server to be
   started and stopped automatically when your system starts and
   stops. You should also assign passwords to the accounts in the
   grant tables.

   On Unix, the grant tables are set up by the mysql_install_db
   program. For some installation methods, this program is run for
   you automatically if an existing database cannot be found.

     * If you install MySQL on Linux using RPM distributions, the
       server RPM runs mysql_install_db.

     * Using the native packaging system on many platforms, including
       Debian Linux, Ubuntu Linux, Gentoo Linux and others, the
       mysql_install_db command is run for you.

     * If you install MySQL on Mac OS X using a PKG distribution, the
       installer runs mysql_install_db.

   For other platforms and installation types, including generic
   binary and source installs, you will need to run mysql_install_db
   yourself.

   The following procedure describes how to initialize the grant
   tables (if that has not previously been done) and start the
   server. It also suggests some commands that you can use to test
   whether the server is accessible and working properly. For
   information about starting and stopping the server automatically,
   see Section 2.10.1.2, "Starting and Stopping MySQL Automatically."

   After you complete the procedure and have the server running, you
   should assign passwords to the accounts created by
   mysql_install_db and perhaps restrict access to test databases.
   For instructions, see Section 2.10.2, "Securing the Initial MySQL
   Accounts."

   In the examples shown here, the server runs under the user ID of
   the mysql login account. This assumes that such an account exists.
   Either create the account if it does not exist, or substitute the
   name of a different existing login account that you plan to use
   for running the server. For information about creating the
   account, see Creating a mysql System User and Group, in Section
   2.2, "Installing MySQL from Generic Binaries on Unix/Linux."

    1. Change location into the top-level directory of your MySQL
       installation, represented here by BASEDIR:
shell> cd BASEDIR
       BASEDIR is the installation directory for your MySQL instance.
       It is likely to be something like /usr/local/mysql or
       /usr/local. The following steps assume that you have changed
       location to this directory.
       You will find several files and subdirectories in the BASEDIR
       directory. The most important for installation purposes are
       the bin and scripts subdirectories:

          + The bin directory contains client programs and the
            server. You should add the full path name of this
            directory to your PATH environment variable so that your
            shell finds the MySQL programs properly. See Section
            2.12, "Environment Variables."

          + The scripts directory contains the mysql_install_db
            script used to initialize the mysql database containing
            the grant tables that store the server access
            permissions.

    2. If necessary, ensure that the distribution contents are
       accessible to mysql. If you installed the distribution as
       mysql, no further action is required. If you installed the
       distribution as root, its contents will be owned by root.
       Change its ownership to mysql by executing the following
       commands as root in the installation directory. The first
       command changes the owner attribute of the files to the mysql
       user. The second changes the group attribute to the mysql
       group.
shell> chown -R mysql .
shell> chgrp -R mysql .

    3. If necessary, run the mysql_install_db program to set up the
       initial MySQL grant tables containing the privileges that
       determine how users are permitted to connect to the server.
       You will need to do this if you used a distribution type for
       which the installation procedure does not run the program for
       you.
shell> scripts/mysql_install_db --user=mysql
       Typically, mysql_install_db needs to be run only the first
       time you install MySQL, so you can skip this step if you are
       upgrading an existing installation, However, mysql_install_db
       does not overwrite any existing privilege tables, so it should
       be safe to run in any circumstances.
       It might be necessary to specify other options such as
       --basedir or --datadir if mysql_install_db does not identify
       the correct locations for the installation directory or data
       directory. For example:
shell> scripts/mysql_install_db --user=mysql \
         --basedir=/opt/mysql/mysql \
         --datadir=/opt/mysql/mysql/data
       The mysql_install_db script creates the server's data
       directory with mysql as the owner. Under the data directory,
       it creates directories for the mysql database that holds the
       grant tables and the test database that you can use to test
       MySQL. The script also creates privilege table entries for
       root and anonymous-user accounts. The accounts have no
       passwords initially. Section 2.10.2, "Securing the Initial
       MySQL Accounts," describes the initial privileges. Briefly,
       these privileges permit the MySQL root user to do anything,
       and permit anybody to create or use databases with a name of
       test or starting with test_. See Section 5.4, "The MySQL
       Access Privilege System," for a complete listing and
       description of the grant tables.
       It is important to make sure that the database directories and
       files are owned by the mysql login account so that the server
       has read and write access to them when you run it later. To
       ensure this if you run mysql_install_db as root, include the
       --user option as shown. Otherwise, you should execute the
       script while logged in as mysql, in which case you can omit
       the --user option from the command.
       If you do not want to have the test database, you can remove
       it after starting the server, using the instructions in
       Section 2.10.2, "Securing the Initial MySQL Accounts."
       If you have trouble with mysql_install_db at this point, see
       Section 2.10.1.1, "Problems Running mysql_install_db."

    4. Most of the MySQL installation can be owned by root if you
       like. The exception is that the data directory must be owned
       by mysql. To accomplish this, run the following commands as
       root in the installation directory:
shell> chown -R root .
shell> chown -R mysql data

    5. If the plugin directory (the directory named by the plugin_dir
       system variable) is writable by the server, it may be possible
       for a user to write executable code to a file in the directory
       using SELECT ... INTO DUMPFILE. This can be prevented by
       making plugin_dir read only to the server or by setting
       --secure-file-priv to a directory where SELECT writes can be
       made safely.

    6. If you installed MySQL using a source distribution, you may
       want to optionally copy one of the provided configuration
       files from the support-files directory into your /etc
       directory. There are different sample configuration files for
       different use cases, server types, and CPU and RAM
       configurations. If you want to use one of these standard
       files, you should copy it to /etc/my.cnf, or /etc/mysql/my.cnf
       and edit and check the configuration before starting your
       MySQL server for the first time.
       If you do not copy one of the standard configuration files,
       the MySQL server will be started with the default settings.
       If you want MySQL to start automatically when you boot your
       machine, you can copy support-files/mysql.server to the
       location where your system has its startup files. More
       information can be found in the mysql.server script itself,
       and in Section 2.10.1.2, "Starting and Stopping MySQL
       Automatically."

    7. Start the MySQL server:
shell> bin/mysqld_safe --user=mysql &
       It is important that the MySQL server be run using an
       unprivileged (non-root) login account. To ensure this if you
       run mysqld_safe as root, include the --user option as shown.
       Otherwise, you should execute the script while logged in as
       mysql, in which case you can omit the --user option from the
       command.
       For further instructions for running MySQL as an unprivileged
       user, see Section 5.3.6, "How to Run MySQL as a Normal User."
       If the command fails immediately and prints mysqld ended, look
       for information in the error log (which by default is the
       host_name.err file in the data directory).
       If you neglected to create the grant tables by running
       mysql_install_db before proceeding to this step, the following
       message appears in the error log file when you start the
       server:
mysqld: Can't find file: 'host.frm'
       This error also occurs if you run mysql_install_db as root
       without the --user option. Remove the data directory and run
       mysql_install_db with the --user option as described
       previously.
       If you have other problems starting the server, see Section
       2.10.1.3, "Starting and Troubleshooting the MySQL Server." For
       more information about mysqld_safe, see Section 4.3.2,
       "mysqld_safe --- MySQL Server Startup Script."

    8. Use mysqladmin to verify that the server is running. The
       following commands provide simple tests to check whether the
       server is up and responding to connections:
shell> bin/mysqladmin version
shell> bin/mysqladmin variables
       The output from mysqladmin version varies slightly depending
       on your platform and version of MySQL, but should be similar
       to that shown here:
shell> bin/mysqladmin version
mysqladmin  Ver 14.12 Distrib 5.6.3, for pc-linux-gnu on i686
...

Server version          5.6.3
Protocol version        10
Connection              Localhost via UNIX socket
UNIX socket             /var/lib/mysql/mysql.sock
Uptime:                 14 days 5 hours 5 min 21 sec

Threads: 1  Questions: 366  Slow queries: 0
Opens: 0  Flush tables: 1  Open tables: 19
Queries per second avg: 0.000
       To see what else you can do with mysqladmin, invoke it with
       the --help option.

    9. Verify that you can shut down the server:
shell> bin/mysqladmin -u root shutdown
   10. Verify that you can start the server again. Do this by using
       mysqld_safe or by invoking mysqld directly. For example:
shell> bin/mysqld_safe --user=mysql &
       If mysqld_safe fails, see Section 2.10.1.3, "Starting and
       Troubleshooting the MySQL Server."
   11. Run some simple tests to verify that you can retrieve
       information from the server. The output should be similar to
       what is shown here:
shell> bin/mysqlshow
+--------------------+
|     Databases      |
+--------------------+
| information_schema |
| mysql              |
| test               |
+--------------------+

shell> bin/mysqlshow mysql
Database: mysql
+---------------------------+
|          Tables           |
+---------------------------+
| columns_priv              |
| db                        |
| event                     |
| func                      |
| help_category             |
| help_keyword              |
| help_relation             |
| help_topic                |
| host                      |
| plugin                    |
| proc                      |
| procs_priv                |
| servers                   |
| tables_priv               |
| time_zone                 |
| time_zone_leap_second     |
| time_zone_name            |
| time_zone_transition      |
| time_zone_transition_type |
| user                      |
+---------------------------+

shell> bin/mysql -e "SELECT Host,Db,User FROM db" mysql
+------+--------+------+
| host | db     | user |
+------+--------+------+
| %    | test   |      |
| %    | test_% |      |
+------+--------+------+
   12. There is a benchmark suite in the sql-bench directory (under
       the MySQL installation directory) that you can use to compare
       how MySQL performs on different platforms. The benchmark suite
       is written in Perl. It requires the Perl DBI module that
       provides a database-independent interface to the various
       databases, and some other additional Perl modules:
DBI
DBD::mysql
Data::Dumper
Data::ShowTable
       These modules can be obtained from CPAN
       (). See also Section 2.13.1, "Installing
       Perl on Unix."
       The sql-bench/Results directory contains the results from many
       runs against different databases and platforms. To run all
       tests, execute these commands:
shell> cd sql-bench
shell> perl run-all-tests
       If you do not have the sql-bench directory, you probably
       installed MySQL using RPM files other than the source RPM.
       (The source RPM includes the sql-bench benchmark directory.)
       In this case, you must first install the benchmark suite
       before you can use it. There are separate benchmark RPM files
       named mysql-bench-VERSION.i386.rpm that contain benchmark code
       and data.
       If you have a source distribution, there are also tests in its
       tests subdirectory that you can run. For example, to run
       auto_increment.tst, execute this command from the top-level
       directory of your source distribution:
shell> mysql -vvf test < ./tests/auto_increment.tst
       The expected result of the test can be found in the
       ./tests/auto_increment.res file.
   13. At this point, you should have the server running. However,
       none of the initial MySQL accounts have a password, and the
       server permits permissive access to test databases. To tighten
       security, follow the instructions in Section 2.10.2, "Securing
       the Initial MySQL Accounts."

   The MySQL 5.6 installation procedure creates time zone tables in
   the mysql database but does not populate them. To do so, use the
   instructions in Section 9.6, "MySQL Server Time Zone Support."

   To make it more convenient to invoke programs installed in the bin
   directory under the installation directory, you can add that
   directory to your PATH environment variable setting. That enables
   you to run a program by typing only its name, not its entire path
   name. See Section 4.2.4, "Setting Environment Variables."

   You can set up new accounts using the bin/mysql_setpermission
   script if you install the DBI and DBD::mysql Perl modules. See
   Section 4.6.13, "mysql_setpermission --- Interactively Set
   Permissions in Grant Tables." For Perl module installation
   instructions, see Section 2.13, "Perl Installation Notes."

   If you would like to use mysqlaccess and have the MySQL
   distribution in some nonstandard location, you must change the
   location where mysqlaccess expects to find the mysql client. Edit
   the bin/mysqlaccess script at approximately line 18. Search for a
   line that looks like this:
$MYSQL     = '/usr/local/bin/mysql';    # path to mysql executable

   Change the path to reflect the location where mysql actually is
   stored on your system. If you do not do this, a Broken pipe error
   will occur when you run mysqlaccess.

2.10.1.1. Problems Running mysql_install_db

   The purpose of the mysql_install_db script is to generate new
   MySQL privilege tables. It does not overwrite existing MySQL
   privilege tables, and it does not affect any other data.

   If you want to re-create your privilege tables, first stop the
   mysqld server if it is running. Then rename the mysql directory
   under the data directory to save it, and then run
   mysql_install_db. Suppose that your current directory is the MySQL
   installation directory and that mysql_install_db is located in the
   bin directory and the data directory is named data. To rename the
   mysql database and re-run mysql_install_db, use these commands.
shell> mv data/mysql data/mysql.old
shell> scripts/mysql_install_db --user=mysql

   When you run mysql_install_db, you might encounter the following
   problems:

     * mysql_install_db fails to install the grant tables
       You may find that mysql_install_db fails to install the grant
       tables and terminates after displaying the following messages:
Starting mysqld daemon with databases from XXXXXX
mysqld ended
       In this case, you should examine the error log file very
       carefully. The log should be located in the directory XXXXXX
       named by the error message and should indicate why mysqld did
       not start. If you do not understand what happened, include the
       log when you post a bug report. See Section 1.7, "How to
       Report Bugs or Problems."

     * There is a mysqld process running
       This indicates that the server is running, in which case the
       grant tables have probably been created already. If so, there
       is no need to run mysql_install_db at all because it needs to
       be run only once (when you install MySQL the first time).

     * Installing a second mysqld server does not work when one
       server is running
       This can happen when you have an existing MySQL installation,
       but want to put a new installation in a different location.
       For example, you might have a production installation, but you
       want to create a second installation for testing purposes.
       Generally the problem that occurs when you try to run a second
       server is that it tries to use a network interface that is in
       use by the first server. In this case, you should see one of
       the following error messages:
Can't start server: Bind on TCP/IP port:
Address already in use
Can't start server: Bind on unix socket...
       For instructions on setting up multiple servers, see Section
       5.6, "Running Multiple MySQL Instances on One Machine."

     * You do not have write access to the /tmp directory
       If you do not have write access to create temporary files or a
       Unix socket file in the default location (the /tmp directory)
       or the TMP_DIR environment variable, if it has been set, an
       error occurs when you run mysql_install_db or the mysqld
       server.
       You can specify different locations for the temporary
       directory and Unix socket file by executing these commands
       prior to starting mysql_install_db or mysqld, where
       some_tmp_dir is the full path name to some directory for which
       you have write permission:
shell> TMPDIR=/some_tmp_dir/
shell> MYSQL_UNIX_PORT=/some_tmp_dir/mysql.sock
shell> export TMPDIR MYSQL_UNIX_PORT
       Then you should be able to run mysql_install_db and start the
       server with these commands:
shell> scripts/mysql_install_db --user=mysql
shell> bin/mysqld_safe --user=mysql &
       If mysql_install_db is located in the scripts directory,
       modify the first command to scripts/mysql_install_db.
       See Section C.5.4.5, "How to Protect or Change the MySQL Unix
       Socket File," and Section 2.12, "Environment Variables."

   There are some alternatives to running the mysql_install_db script
   provided in the MySQL distribution:

     * If you want the initial privileges to be different from the
       standard defaults, you can modify mysql_install_db before you
       run it. However, it is preferable to use GRANT and REVOKE to
       change the privileges after the grant tables have been set up.
       In other words, you can run mysql_install_db, and then use
       mysql -u root mysql to connect to the server as the MySQL root
       user so that you can issue the necessary GRANT and REVOKE
       statements.
       If you want to install MySQL on several machines with the same
       privileges, you can put the GRANT and REVOKE statements in a
       file and execute the file as a script using mysql after
       running mysql_install_db. For example:
shell> scripts/mysql_install_db --user=mysql
shell> bin/mysql -u root < your_script_file
       By doing this, you can avoid having to issue the statements
       manually on each machine.

     * It is possible to re-create the grant tables completely after
       they have previously been created. You might want to do this
       if you are just learning how to use GRANT and REVOKE and have
       made so many modifications after running mysql_install_db that
       you want to wipe out the tables and start over.
       To re-create the grant tables, remove all the .frm, .MYI, and
       .MYD files in the mysql database directory. Then run the
       mysql_install_db script again.

     * You can start mysqld manually using the --skip-grant-tables
       option and add the privilege information yourself using mysql:
shell> bin/mysqld_safe --user=mysql --skip-grant-tables &
shell> bin/mysql mysql
       From mysql, manually execute the SQL commands contained in
       mysql_install_db. Make sure that you run mysqladmin
       flush-privileges or mysqladmin reload afterward to tell the
       server to reload the grant tables.
       Note that by not using mysql_install_db, you not only have to
       populate the grant tables manually, you also have to create
       them first.

2.10.1.2. Starting and Stopping MySQL Automatically

   Generally, you start the mysqld server in one of these ways:

     * Invoke mysqld directly. This works on any platform.

     * Run the MySQL server as a Windows service. The service can be
       set to start the server automatically when Windows starts, or
       as a manual service that you start on request. For
       instructions, see Section 2.3.5.7, "Starting MySQL as a
       Windows Service."

     * Invoke mysqld_safe, which tries to determine the proper
       options for mysqld and then runs it with those options. This
       script is used on Unix and Unix-like systems. See Section
       4.3.2, "mysqld_safe --- MySQL Server Startup Script."

     * Invoke mysql.server. This script is used primarily at system
       startup and shutdown on systems that use System V-style run
       directories (that is, /etc/init.d and run-level specific
       directories), where it usually is installed under the name
       mysql. The mysql.server script starts the server by invoking
       mysqld_safe. See Section 4.3.3, "mysql.server --- MySQL Server
       Startup Script."

     * On Mac OS X, install a separate MySQL Startup Item package to
       enable the automatic startup of MySQL on system startup. The
       Startup Item starts the server by invoking mysql.server. See
       Section 2.4.3, "Installing the MySQL Startup Item," for
       details. A MySQL Preference Pane also provides control for
       starting and stopping MySQL through the System Preferences,
       see Section 2.4.4, "Installing and Using the MySQL Preference
       Pane."

     * Use the Solaris/OpenSolaris service management framework (SMF)
       system to initiate and control MySQL startup. For more
       information, see Section 2.6.2, "Installing MySQL on
       OpenSolaris using IPS."

   The mysqld_safe and mysql.server scripts, Windows server,
   Solaris/OpenSolaris SMF, and the Mac OS X Startup Item (or MySQL
   Preference Pane) can be used to start the server manually, or
   automatically at system startup time. mysql.server and the Startup
   Item also can be used to stop the server.

   To start or stop the server manually using the mysql.server
   script, invoke it with start or stop arguments:
shell> mysql.server start
shell> mysql.server stop

   Before mysql.server starts the server, it changes location to the
   MySQL installation directory, and then invokes mysqld_safe. If you
   want the server to run as some specific user, add an appropriate
   user option to the [mysqld] group of the /etc/my.cnf option file,
   as shown later in this section. (It is possible that you will need
   to edit mysql.server if you've installed a binary distribution of
   MySQL in a nonstandard location. Modify it to change location into
   the proper directory before it runs mysqld_safe. If you do this,
   your modified version of mysql.server may be overwritten if you
   upgrade MySQL in the future, so you should make a copy of your
   edited version that you can reinstall.)

   mysql.server stop stops the server by sending a signal to it. You
   can also stop the server manually by executing mysqladmin
   shutdown.

   To start and stop MySQL automatically on your server, you need to
   add start and stop commands to the appropriate places in your
   /etc/rc* files.

   If you use the Linux server RPM package
   (MySQL-server-VERSION.rpm), or a native Linux package
   installation, the mysql.server script may be installed in the
   /etc/init.d directory with the name mysql. See Section 2.5.1,
   "Installing MySQL from RPM Packages on Linux," for more
   information on the Linux RPM packages.

   Some vendors provide RPM packages that install a startup script
   under a different name such as mysqld.

   If you install MySQL from a source distribution or using a binary
   distribution format that does not install mysql.server
   automatically, you can install it manually. The script can be
   found in the support-files directory under the MySQL installation
   directory or in a MySQL source tree.

   To install mysql.server manually, copy it to the /etc/init.d
   directory with the name mysql, and then make it executable. Do
   this by changing location into the appropriate directory where
   mysql.server is located and executing these commands:
shell> cp mysql.server /etc/init.d/mysql
shell> chmod +x /etc/init.d/mysql

   Note

   Older Red Hat systems use the /etc/rc.d/init.d directory rather
   than /etc/init.d. Adjust the preceding commands accordingly.
   Alternatively, first create /etc/init.d as a symbolic link that
   points to /etc/rc.d/init.d:
shell> cd /etc
shell> ln -s rc.d/init.d .

   After installing the script, the commands needed to activate it to
   run at system startup depend on your operating system. On Linux,
   you can use chkconfig:
shell> chkconfig --add mysql

   On some Linux systems, the following command also seems to be
   necessary to fully enable the mysql script:
shell> chkconfig --level 345 mysql on

   On FreeBSD, startup scripts generally should go in
   /usr/local/etc/rc.d/. The rc(8) manual page states that scripts in
   this directory are executed only if their basename matches the
   *.sh shell file name pattern. Any other files or directories
   present within the directory are silently ignored. In other words,
   on FreeBSD, you should install the mysql.server script as
   /usr/local/etc/rc.d/mysql.server.sh to enable automatic startup.

   As an alternative to the preceding setup, some operating systems
   also use /etc/rc.local or /etc/init.d/boot.local to start
   additional services on startup. To start up MySQL using this
   method, you could append a command like the one following to the
   appropriate startup file:
/bin/sh -c 'cd /usr/local/mysql; ./bin/mysqld_safe --user=mysql &'

   For other systems, consult your operating system documentation to
   see how to install startup scripts.

   You can add options for mysql.server in a global /etc/my.cnf file.
   A typical /etc/my.cnf file might look like this:
[mysqld]
datadir=/usr/local/mysql/var
socket=/var/tmp/mysql.sock
port=3306
user=mysql

[mysql.server]
basedir=/usr/local/mysql

   The mysql.server script supports the following options: basedir,
   datadir, and pid-file. If specified, they must be placed in an
   option file, not on the command line. mysql.server supports only
   start and stop as command-line arguments.

   The following table shows which option groups the server and each
   startup script read from option files.

   Table 2.15. MySQL Startup scripts and supported server option
   groups
      Script                  Option Groups
   mysqld       [mysqld], [server], [mysqld-major_version]
   mysqld_safe  [mysqld], [server], [mysqld_safe]
   mysql.server [mysqld], [mysql.server], [server]

   [mysqld-major_version] means that groups with names like
   [mysqld-5.5] and [mysqld-5.6] are read by servers having versions
   5.5.x, 5.6.x, and so forth. This feature can be used to specify
   options that can be read only by servers within a given release
   series.

   For backward compatibility, mysql.server also reads the
   [mysql_server] group and mysqld_safe also reads the [safe_mysqld]
   group. However, you should update your option files to use the
   [mysql.server] and [mysqld_safe] groups instead when using MySQL
   5.6.

   For more information on MySQL configuration files and their
   structure and contents, see Section 4.2.3.3, "Using Option Files."

2.10.1.3. Starting and Troubleshooting the MySQL Server

   This section provides troubleshooting suggestions for problems
   starting the server on Unix. If you are using Windows, see Section
   2.3.6, "Troubleshooting a MySQL Installation Under Windows."

   If you have problems starting the server, here are some things to
   try:

     * Check the error log to see why the server does not start.

     * Specify any special options needed by the storage engines you
       are using.

     * Make sure that the server knows where to find the data
       directory.

     * Make sure that the server can access the data directory. The
       ownership and permissions of the data directory and its
       contents must be set such that the server can read and modify
       them.

     * Verify that the network interfaces the server wants to use are
       available.

   Some storage engines have options that control their behavior. You
   can create a my.cnf file and specify startup options for the
   engines that you plan to use. If you are going to use storage
   engines that support transactional tables (InnoDB, NDB
   (http://dev.mysql.com/doc/refman/5.1/en/mysql-cluster.html)), be
   sure that you have them configured the way you want before
   starting the server:

   If you are using InnoDB tables, see Section 13.6.2, "Configuring
   InnoDB."

   Storage engines will use default option values if you specify
   none, but it is recommended that you review the available options
   and specify explicit values for those for which the defaults are
   not appropriate for your installation.

   When the mysqld server starts, it changes location to the data
   directory. This is where it expects to find databases and where it
   expects to write log files. The server also writes the pid
   (process ID) file in the data directory.

   The data directory location is hardwired in when the server is
   compiled. This is where the server looks for the data directory by
   default. If the data directory is located somewhere else on your
   system, the server will not work properly. You can determine what
   the default path settings are by invoking mysqld with the
   --verbose and --help options.

   If the default locations do not match the MySQL installation
   layout on your system, you can override them by specifying options
   to mysqld or mysqld_safe on the command line or in an option file.

   To specify the location of the data directory explicitly, use the
   --datadir option. However, normally you can tell mysqld the
   location of the base directory under which MySQL is installed and
   it looks for the data directory there. You can do this with the
   --basedir option.

   To check the effect of specifying path options, invoke mysqld with
   those options followed by the --verbose and --help options. For
   example, if you change location into the directory where mysqld is
   installed and then run the following command, it shows the effect
   of starting the server with a base directory of /usr/local:
shell> ./mysqld --basedir=/usr/local --verbose --help

   You can specify other options such as --datadir as well, but
   --verbose and --help must be the last options.

   Once you determine the path settings you want, start the server
   without --verbose and --help.

   If mysqld is currently running, you can find out what path
   settings it is using by executing this command:
shell> mysqladmin variables

   Or:
shell> mysqladmin -h host_name variables

   host_name is the name of the MySQL server host.

   If you get Errcode 13 (which means Permission denied) when
   starting mysqld, this means that the privileges of the data
   directory or its contents do not permit server access. In this
   case, you change the permissions for the involved files and
   directories so that the server has the right to use them. You can
   also start the server as root, but this raises security issues and
   should be avoided.

   On Unix, change location into the data directory and check the
   ownership of the data directory and its contents to make sure the
   server has access. For example, if the data directory is
   /usr/local/mysql/var, use this command:
shell> ls -la /usr/local/mysql/var

   If the data directory or its files or subdirectories are not owned
   by the login account that you use for running the server, change
   their ownership to that account. If the account is named mysql,
   use these commands:
shell> chown -R mysql /usr/local/mysql/var
shell> chgrp -R mysql /usr/local/mysql/var

   If it possible that even with correct ownership, MySQL may fail to
   start up if there is other security software running on your
   system that manages application access to various parts of the
   file system. In this case, you may need to reconfigure that
   software to enable mysqld to access the directories it uses during
   normal operation.

   If the server fails to start up correctly, check the error log.
   Log files are located in the data directory (typically C:\Program
   Files\MySQL\MySQL Server 5.6\data on Windows,
   /usr/local/mysql/data for a Unix binary distribution, and
   /usr/local/var for a Unix source distribution). Look in the data
   directory for files with names of the form host_name.err and
   host_name.log, where host_name is the name of your server host.
   Then examine the last few lines of these files. On Unix, you can
   use tail to display them:
shell> tail host_name.err
shell> tail host_name.log

   The error log should contain information that indicates why the
   server could not start.

   If either of the following errors occur, it means that some other
   program (perhaps another mysqld server) is using the TCP/IP port
   or Unix socket file that mysqld is trying to use:
Can't start server: Bind on TCP/IP port: Address already in use
Can't start server: Bind on unix socket...

   Use ps to determine whether you have another mysqld server
   running. If so, shut down the server before starting mysqld again.
   (If another server is running, and you really want to run multiple
   servers, you can find information about how to do so in Section
   5.6, "Running Multiple MySQL Instances on One Machine.")

   If no other server is running, try to execute the command telnet
   your_host_name tcp_ip_port_number. (The default MySQL port number
   is 3306.) Then press Enter a couple of times. If you do not get an
   error message like telnet: Unable to connect to remote host:
   Connection refused, some other program is using the TCP/IP port
   that mysqld is trying to use. You will need to track down what
   program this is and disable it, or else tell mysqld to listen to a
   different port with the --port option. In this case, you will also
   need to specify the port number for client programs when
   connecting to the server using TCP/IP.

   Another reason the port might be inaccessible is that you have a
   firewall running that blocks connections to it. If so, modify the
   firewall settings to permit access to the port.

   If the server starts but you cannot connect to it, you should make
   sure that you have an entry in /etc/hosts that looks like this:
127.0.0.1       localhost

   If you cannot get mysqld to start, you can try to make a trace
   file to find the problem by using the --debug option. See MySQL
   Internals: Porting
   ().

2.10.2. Securing the Initial MySQL Accounts

   Part of the MySQL installation process is to set up the mysql
   database that contains the grant tables:

     * Windows distributions contain preinitialized grant tables.

     * On Unix, the mysql_install_db program populates the grant
       tables. Some installation methods run this program for you.
       Others require that you execute it manually. For details, see
       Section 2.10.1, "Unix Postinstallation Procedures."

   The mysql.user grant table defines the initial MySQL user accounts
   and their access privileges:

     * Some accounts have the user name root. These are superuser
       accounts that have all privileges and can do anything. The
       initial root account passwords are empty, so anyone can
       connect to the MySQL server as root without a password and be
       granted all privileges.

          + On Windows, root accounts are created that permit
            connections from the local host only. Connections can be
            made by specifying the host name localhost, the IP
            address 127.0.0.1, or the IPv6 address ::1. If the user
            selects the Enable root access from remote machines
            option during installation, the Windows installer creates
            another root account that permits connections from any
            host.

          + On Unix, each root account permits connections from the
            local host. Connections can be made by specifying the
            host name localhost, the IP address 127.0.0.1, the IPv6
            address ::1, or the actual host name or IP address.
       An attempt to connect to the host 127.0.0.1 normally resolves
       to the localhost account. However, this fails if the server is
       run with the --skip-name-resolve option, so the 127.0.0.1
       account is useful in that case. The ::1 account is used for
       IPv6 connections.

     * Some accounts are for anonymous users. These have an empty
       user name. The anonymous accounts have no password, so anyone
       can use them to connect to the MySQL server.

          + On Windows, there is one anonymous account that permits
            connections from the local host. Connections can be made
            by specifying a host name of localhost.

          + On Unix, each anonymous account permits connections from
            the local host. Connections can be made by specifying a
            host name of localhost for one of the accounts, or the
            actual host name or IP address for the other.

   To display which accounts exist in the mysql.user table and check
   whether their passwords are empty, use the following statement:
mysql> SELECT User, Host, Password FROM mysql.user;
+------+--------------------+----------+
| User | Host               | Password |
+------+--------------------+----------+
| root | localhost          |          |
| root | myhost.example.com |          |
| root | 127.0.0.1          |          |
| root | ::1                |          |
|      | localhost          |          |
|      | myhost.example.com |          |
+------+--------------------+----------+

   This output indicates that there are several root and
   anonymous-user accounts, none of which have passwords. The output
   might differ on your system, but the presence of accounts with
   empty passwords means that your MySQL installation is unprotected
   until you do something about it:

     * You should assign a password to each MySQL root account.

     * If you want to prevent clients from connecting as anonymous
       users without a password, you should either assign a password
       to each anonymous account or else remove the accounts.

   In addition, the mysql.db table contains rows that permit all
   accounts to access the test database and other databases with
   names that start with test_. This is true even for accounts that
   otherwise have no special privileges such as the default anonymous
   accounts. This is convenient for testing but inadvisable on
   production servers. Administrators who want database access
   restricted only to accounts that have permissions granted
   explicitly for that purpose should remove these mysql.db table
   rows.

   The following instructions describe how to set up passwords for
   the initial MySQL accounts, first for the root accounts, then for
   the anonymous accounts. The instructions also cover how to remove
   the anonymous accounts, should you prefer not to permit anonymous
   access at all, and describe how to remove permissive access to
   test databases. Replace newpwd in the examples with the password
   that you want to use. Replace host_name with the name of the
   server host. You can determine this name from the output of the
   preceding SELECT statement. For the output shown, host_name is
   myhost.example.com.
   Note

   For additional information about setting passwords, see Section
   5.5.5, "Assigning Account Passwords." If you forget your root
   password after setting it, see Section C.5.4.1, "How to Reset the
   Root Password."

   You might want to defer setting the passwords until later, to
   avoid the need to specify them while you perform additional setup
   or testing. However, be sure to set them before using your
   installation for production purposes.

   To set up additional accounts, see Section 5.5.2, "Adding User
   Accounts."

Assigning root Account Passwords

   The root account passwords can be set several ways. The following
   discussion demonstrates three methods:

     * Use the SET PASSWORD statement

     * Use the UPDATE statement

     * Use the mysqladmin command-line client program

   To assign passwords using SET PASSWORD, connect to the server as
   root and issue a SET PASSWORD statement for each root account
   listed in the mysql.user table. Be sure to encrypt the password
   using the PASSWORD() function.

   For Windows, do this:
shell> mysql -u root
mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('newpwd');
mysql> SET PASSWORD FOR 'root'@'127.0.0.1' = PASSWORD('newpwd');
mysql> SET PASSWORD FOR 'root'@'::1' = PASSWORD('newpwd');
mysql> SET PASSWORD FOR 'root'@'%' = PASSWORD('newpwd');

   The last statement is unnecessary if the mysql.user table has no
   root account with a host value of %.

   For Unix, do this:
shell> mysql -u root
mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('newpwd');
mysql> SET PASSWORD FOR 'root'@'127.0.0.1' = PASSWORD('newpwd');
mysql> SET PASSWORD FOR 'root'@'::1' = PASSWORD('newpwd');
mysql> SET PASSWORD FOR 'root'@'host_name' = PASSWORD('newpwd');

   You can also use a single statement that assigns a password to all
   root accounts by using UPDATE to modify the mysql.user table
   directly. This method works on any platform:
shell> mysql -u root
mysql> UPDATE mysql.user SET Password = PASSWORD('newpwd')
    ->     WHERE User = 'root';
mysql> FLUSH PRIVILEGES;

   The FLUSH statement causes the server to reread the grant tables.
   Without it, the password change remains unnoticed by the server
   until you restart it.

   To assign passwords to the root accounts using mysqladmin, execute
   the following commands:
shell> mysqladmin -u root password "newpwd"
shell> mysqladmin -u root -h host_name password "newpwd"

   Those commands apply both to Windows and to Unix. The double
   quotation marks around the password are not always necessary, but
   you should use them if the password contains spaces or other
   characters that are special to your command interpreter.

   The mysqladmin method of setting the root account passwords does
   not work for the 'root'@'127.0.0.1' or 'root'@'::1' account. Use
   the SET PASSWORD method shown earlier.

   After the root passwords have been set, you must supply the
   appropriate password whenever you connect as root to the server.
   For example, to shut down the server with mysqladmin, use this
   command:
shell> mysqladmin -u root -p shutdown
Enter password: (enter root password here)

Assigning Anonymous Account Passwords

   The mysql commands in the following instructions include a -p
   option based on the assumption that you have set the root account
   passwords using the preceding instructions and must specify that
   password when connecting to the server.

   To assign passwords to the anonymous accounts, connect to the
   server as root, then use either SET PASSWORD or UPDATE. Be sure to
   encrypt the password using the PASSWORD() function.

   To use SET PASSWORD on Windows, do this:
shell> mysql -u root -p
Enter password: (enter root password here)
mysql> SET PASSWORD FOR ''@'localhost' = PASSWORD('newpwd');

   To use SET PASSWORD on Unix, do this:
shell> mysql -u root -p
Enter password: (enter root password here)
mysql> SET PASSWORD FOR ''@'localhost' = PASSWORD('newpwd');
mysql> SET PASSWORD FOR ''@'host_name' = PASSWORD('newpwd');

   To set the anonymous-user account passwords with a single UPDATE
   statement, do this (on any platform):
shell> mysql -u root -p
Enter password: (enter root password here)
mysql> UPDATE mysql.user SET Password = PASSWORD('newpwd')
    ->     WHERE User = '';
mysql> FLUSH PRIVILEGES;

   The FLUSH statement causes the server to reread the grant tables.
   Without it, the password change remains unnoticed by the server
   until you restart it.

Removing Anonymous Accounts

   If you prefer to remove any anonymous accounts rather than
   assigning them passwords, do so as follows on Windows:
shell> mysql -u root -p
Enter password: (enter root password here)
mysql> DROP USER ''@'localhost';

   On Unix, remove the anonymous accounts like this:
shell> mysql -u root -p
Enter password: (enter root password here)
mysql> DROP USER ''@'localhost';
mysql> DROP USER ''@'host_name';

Securing Test Databases

   By default, the mysql.db table contains rows that permit access by
   any user to the test database and other databases with names that
   start with test_. (These rows have an empty User column value,
   which for access-checking purposes matches any user name.) This
   means that such databases can be used even by accounts that
   otherwise possess no privileges. If you want to remove any-user
   access to test databases, do so as follows:
shell> mysql -u root -p
Enter password: (enter root password here)
mysql> DELETE FROM mysql.db WHERE Db LIKE 'test%';
mysql> FLUSH PRIVILEGES;

   The FLUSH statement causes the server to reread the grant tables.
   Without it, the privilege change remains unnoticed by the server
   until you restart it.

   With the preceding change, only users who have global database
   privileges or privileges granted explicitly for the test database
   can use it. However, if you do not want the database to exist at
   all, drop it:
mysql> DROP DATABASE test;

   Note

   On Windows, you can also perform the process described in this
   section using the Configuration Wizard (see Section 2.3.4.11, "The
   Security Options Dialog"). On other platforms, the MySQL
   distribution includes mysql_secure_installation, a command-line
   utility that automates much of the process of securing a MySQL
   installation.

阅读(1575) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~