Mysql source code assembly details

Source: Internet
Author: User
Mysql provides three installation methods: binary, rpm, and source code compilation. Here we will discuss in detail how to compile and install mysql source code. After mysql 5.5, mysql no longer provides the configure compilation method. Instead, it uses the cmake compilation tool. A notable feature of the cmake tool is that its compilation is independent of the source code, that is, I

Mysql provides three installation methods: binary, rpm, and source code compilation. Here we will discuss in detail how to compile and install mysql source code. After mysql 5.5, mysql no longer provides the configure compilation method. Instead, it uses the cmake compilation tool. A notable feature of the cmake tool is that its compilation is independent of the source code, that is, I

Mysql source code Installation Details

Mysql provides three installation methods: binary, rpm, and source code compilation. Here we will discuss in detail how to compile and install mysql source code.

Mysql does not support configure compilation after version 5.5. Instead, it uses the cmake compilation tool. A notable feature of the cmake tool is that it is compiled independently of the source code, that is, we can use cmake to compile mysql in a directory other than the source code, such

[Root @ easy tmp] # ls-l | grep mysqldrwxr-xr-x 2 root 4096 April 29 21:11 mysql2drwxr-xr-x 33 7161 wheel 4096 March 15 03:07 mysql-5.6.17-rw-r -- r -- 1 easy oinstall 32862539 April 23 20:52 mysql-5.6.17.tar.gzdrwx ------ 2 easy oinstall 4096 April 27 22:43 mysql-workbench.easy [root @ easy tmp] # cd mysql2 [root @ easy mysql2] # cmake .. mysql-5.6.17

In this way, the source files can be compiled multiple times in different directories without affecting each other.

With cmake, you can use-LAH to obtain all the compilation options.

[root@easy mysql1]# cmake ../mysql-5.6.17 -LAH-- Running cmake version 2.6.4-- MySQL 5.6.17-- Packaging as: mysql-5.6.17-Linux-x86_64-- HAVE_VISIBILITY_HIDDEN-- HAVE_VISIBILITY_HIDDEN-- HAVE_VISIBILITY_HIDDEN-- Using cmake version 2.6.4-- Not building NDB-- Library mysqlclient depends on OSLIBS -lpthread;m;rt;dl-- Library mysqlserver depends on OSLIBS -lpthread;m;rt;crypt;dl;aio-- Configuring done-- Generating done-- Build files have been written to: /tmp/mysql1-- Cache values// path to the executableACLOCAL_EXECUTABLE:FILEPATH=/usr/bin/aclocal.....// Missing descriptionWITH_ZLIB:STRING=bundled


To clear the compilation information, run the following command:

[Root @ easy mysql1] # make clean [root @ easy mysql1] # rm CMakeCache.txt rm: Do you want to delete a common file "CMakeCache.txt "? Y

Compilation options:

Some options are used to specify the path of the executable file used during the compilation process, such as ACLOCAL_EXECUTABLE: FILEPATH =/usr/bin/aclocal. You can study it on your own.


-DBUILD_CONFIG = mysql_release
This option enables the compiler to compile the program based on the oracle generate official version options. For example:

cmake -DBUILD_CONFIG=mysql_release

?
-DCMAKE_BUILD_TYPE = type
This option has two selection values
? RelWithDebInfo: default value. optimizations is enabled and debugging information is generated at the same time.
? Debug: Disable optimizations and generate debugging information, which has the same effect as-DWITH_DEBUG = 1.
?
-DCPACK_MONOLITHIC_INSTALL = bool

This option affects the make package operation. If it is set to true, a single file is generated. Otherwise, multiple files are generated. Multiple files are generated by default.


The CMAKE_INSTALL_PREFIX option indicates the base installation directory. Other options
Names of the form INSTALL_xxx that indicate component locations are interpreted relative to
Prefix and their values are relative pathnames. Their values shocould not include the prefix.
?
-DCMAKE_INSTALL_PREFIX = dir_name

This option specifies the mysql installation directory. In addition to specifying this value during compilation, we can also use basedir monthly to set the benchmark directory at mysql startup. During compilation, the options in INSTALL_XXX format are relative paths relative to the PREFIX.
?
-DINSTALL_BINDIR = dir_name
Binfile directory
?
-DINSTALL_LAYOUT = name
Based on the predefined file layout, We can manually set the location of some directories.
? 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 ).
As follows:
Shell> cmake.-DINSTALL_LAYOUT = SVR4-DMYSQL_DATADIR =/var/mysql/data
?
-DINSTALL_MYSQLTESTDIR = dir_name
Where to install the mysql-test directory. As of MySQL 5.6.12, to suppress installation of this
Directory, explicitly set the option to the empty value (-DINSTALL_MYSQLTESTDIR = ).
?
-DINSTALL_SQLBENCHDIR = dir_name
Where to install the SQL-statements directory. To suppress installation of this directory, explicitly set
Option to the empty value (-DINSTALL_SQLBENCHDIR = ).
?
-DMYSQL_DATADIR = dir_name
Specifies the location of the data file. You can also use -- datadir to set it after installation.


?
-DODBC_INCLUDES = dir_name
The location of the ODBC Connector des directory, and may be used while using ing Connector/ODBC. (It may be used when odbc is configured)
?
-DODBC_LIB_DIR = dir_name
The location of the ODBC library directory, and may be used while initializing ing Connector/ODBC.
?
-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.


When compiling mysql, we can specify how to compile the storage engine into mysql: static compilation and dynamic compilation. I personally think the server for static compilation is more efficient.

By default, the four storage engines MyISAM, MERGE, MEMORY, and CSV are required and will be statically compiled into the server. If you need to compile other storage engines statically, you can use the following parameters:

-DWITH_engine_STORAGE_ENGINE = 1

The engine values include ARCHIVE, BLACKHOLE, EXAMPLE, FEDERATED, INNOBASE, NDB or NDBCLUSTER (NDB), PARTITION (partitioning support), and PERFSCHEMA (Performance Schema ).

We can also exclude a storage engine, such

-DWITHOUT_engine_STORAGE_ENGINE = 1.

If a certain engine is neither displayed nor excluded, mysql will compile the engine into a shared module. If it cannot be compiled into a shared module, the engine will be excluded.


-DDEFAULT_CHARSET = charset_name

Specifies the default character set for the database, which can be found under cmake/charset-sets.cmake

-DDEFAULT_COLLATION = collation_name

Specify the database sorting method. You can use the -- collation_server option to specify the database startup mode. You can use the show collation command to view the optional sorting methods.

-DENABLE_DEBUG_SYNC = bool

This function is used to enable mysql synchronization debugging. By default, this function is enabled, but it takes effect only when mysql is configured to enable debugging. This feature is enabled and disabled at runtime. You need to use the -- debug-sync-timeout = N option to start the mysql server. The default value is n 0, that is, this function is disabled. If n is greater than 0, synchronization debugging will wait for n time units; otherwise, it will time out.

?
-DENABLE_DOWNLOADS = bool
Used to download some optional files, such as google's test branch.

-DENABLE_DTRACE = bool
Enable dtrace?
?
-DENABLE_GCOV = bool
Whether to include gcov support (Linux only ).
?
-DENABLE_GPROF = bool
Whether to enable gprof (optimized Linux builds only). This option was added in MySQL 5.6.6.
?
-DENABLED_LOCAL_INFILE = bool
Enables the mysql client to have the load data infile function, which has security risks,

?
-DENABLED_PROFILING = bool
Whether to enable the PROFILING function. We recommend that you enable it for performance monitoring.


?
-DIGNORE_AIO_CHECK = bool
If the-DBUILD_CONFIG = mysql_release option is given on Linux, the libaio library must be
Linked in by default. If you do not have libaio or do not want to install it, you can suppress
Check for it by specifying-DIGNORE_AIO_CHECK = 1. This option was added in MySQL 5.6.1.
?
-DINNODB_PAGE_ATOMIC_REF_COUNT = bool
Whether to enable or disable atomic page reference counting. Fetching and releasing pages from the buffer pool and tracking the page state are expensive and complex operations. Using a page
Mutex to track these operations does not scale well. With INNODB_PAGE_ATOMIC_REF_COUNT = ON (default), fetch and release is tracked using atomics where available. For platforms that do not
Support atomics, set INNODB_PAGE_ATOMIC_REF_COUNT = OFF to disable atomic page reference counting.
When atomic page reference counting is enabled (default), "[Note] InnoDB: Using atomics
To ref count buffer pool pages "is printed to the error log at server startup. if atomic page reference counting is disabled, "[Note] InnoDB: Using mutexes to ref count buffer pool pages" is printed instead.
This build option was introduced with the fix for MySQL Bug #68079.
?
-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 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.

?
-DOPTIMIZER_TRACE = bool
Whether to support optimizer tracing. See MySQL Internals: Tracing the Optimizer. This option was added in MySQL 5.6.3.
?
-Dwith_133 = bool
Whether to enable AddressSanitizer, for compilers that support it. The default is off. This option was added in MySQL 5.6.15.
?
-DWITH_DEBUG = bool
Whether to include debugging support.
Logging ing 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_DEFAULT_FEATURE_SET = bool
Whether to use the flags from cmake/build_deployments/feature_set.cmake. This
Option was added in MySQL 5.6.6.
?
-DWITH_EDITLINE = value
Which libedit/editline library to use. The permitted values are bundled (the default) and
System.
WITH_EDITLINE was added in MySQL 5.6.12. It replaces WITH_LIBEDIT, which has been
Removed.
?
-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_INNODB_MEMCACHED = bool
Whether to generate memcached shared libraries (libmemcached. so and innodb_engine.so ).

?
-DWITH_LIBEVENT = string
Which libevent library to use. Permitted values are bundled (default), system, and yes. If
You specify system or yes, the system libevent library is used if present. If the system library
Is not found, the bundled libevent library is used. The libevent library is required by InnoDB
Memcached.

-DWITH_LIBEDIT = bool
Whether to use the libedit library bundled with the distribution.
WITH_LIBEDIT was removed in MySQL 5.6.12. Use WITH_EDITLINE instead.
?
-DWITH_LIBWRAP = bool
Whether to include libwrap (TCP wrappers) support.
?
-DWITH_READLINE = bool
Whether to use the readline library bundled with the distribution. This option was removed in
MySQL 5.6.5 because readline is no longer bundled.

?
-DWITH_UNIXODBC = 1
Enables unixODBC support, for Connector/ODBC.

?
-DWITH_ZLIB = zlib_type
Some features require that the server be built with compression library support, such as
COMPRESS () and UNCOMPRESS () functions, and compression of the client/server protocol.
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.
?
-DWITHOUT_SERVER = bool
Whether to build without the MySQL server. The default is OFF, which does build the server.



After understanding the meaning of each option, you can run the following installation:

# Preconfiguration setupshell> groupadd mysqlshell> useradd -r -g mysql mysql# Beginning of source-build specific instructionsshell> tar zxvf mysql-VERSION.tar.gzshell> cd mysql-VERSIONshell> cmake .shell> makeshell> make install# End of source-build specific instructions# Postinstallation setupshell> cd /usr/local/mysqlshell> chown -R mysql .shell> chgrp -R mysql .shell> scripts/mysql_install_db --user=mysqlshell> chown -R root .shell> chown -R mysql datashell> bin/mysqld_safe --user=mysql &# Next command is optionalshell> cp support-files/mysql.server /etc/init.d/mysql.server

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.