从源代码构建MYSQL

注:cmake需要手动安装,一般操作系统中不自带。

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."



下面是一些常用选择:
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
我的opensuse是/etc/init.d/这个目录。

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

修改密码
./bin/mysqladmin -u root password 'new-password'
./bin/mysqladmin -u root -h linux-bfss password 'new-password'
Alternatively you can run:
./bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the manual for more instructions.
启动服务
You can start the MySQL daemon with:
cd . ; ./bin/mysqld_safe &
测试脚本
You can test the MySQL daemon with mysql-test-run.pl
cd ./mysql-test ; perl mysql-test-run.pl

Please report any problems with the ./bin/mysqlbug script!

猜你喜欢

转载自chinese-darren.iteye.com/blog/1351243