Related Documentation Download this Excerpt
PDF (US Ltr) - 279.8Kb
PDF (A4) - 280.2Kb
EPUB - 97.2Kb
HTML Download (TGZ) - 63.4Kb
HTML Download (Zip) - 79.7Kb

Building MySQL from Source  /  MySQL Source-Configuration Options

Chapter 4 MySQL Source-Configuration Options

The configure script provides a great deal of control over how you configure a MySQL source distribution. Typically, you do this using options on the configure command line. For a full list of options supported by configure, run this command:

shell> ./configure --help

You can also affect configure using certain environment variables. See Environment Variables.

The following table shows the available configure options.

Table 4.1 MySQL Source-Configuration Option Reference (configure)

--bindirUser executablesEPREFIX/bin
--buildConfigure for building on BUILDguessed
--cache-fileCache test results in FILEdisabled
--config-cacheAlias for `--cache-file=config.cache'
--datadirRead-only architecture-independent dataPREFIX/share
--disable-FEATUREDo not include FEATURE
--disable-community-featuresDisable additional features provided by the community 5.1.28
--disable-dependency-trackingDisable dependency tracking
--disable-grant-optionsDisable GRANT options
--disable-largefileOmit support for large files
--disable-libtool-lockDisable libtool lock
--disable-thread-safe-clientCompile the client without threads 5.1.7
--enable-FEATUREEnable FEATURE
--enable-assemblerUse assembler versions of some string functions if available
--enable-debug-syncCompile in Debug Sync facility 5.1.41
--enable-dependency-trackingDo not reject slow dependency extractors
--enable-fast-installOptimize for fast installationyes
--enable-local-infileEnable LOCAL for LOAD DATA INFILEdisabled
--enable-profilingBuild a version with query profiling code 5.1.24
--enable-sharedBuild shared librariesyes
--enable-staticBuild static librariesyes
--enable-thread-safe-clientCompile the client with threads 5.1.6
--exec-prefixInstall architecture-dependent files in EPREFIX
--helpDisplay help message and exit
--hostCross-compile to build programs to run on HOST
--includedirC header filesPREFIX/include
--infodirInfo documentationPREFIX/info
--libdirObject code librariesEPREFIX/lib
--libexecdirProgram executablesEPREFIX/libexec
--localstatedirModifiable single-machine dataPREFIX/var
--mandirman documentationPREFIX/man
--no-createDo not create output files
--oldincludedirC header files for non-gcc/usr/include
--prefixInstall architecture-independent files in PREFIX
--program-prefixPrepend PREFIX to installed program names
--program-suffixAppend SUFFIX to installed program names
--program-transform-namerun sed PROGRAM on installed program names
--quietDo not print `checking...' messages
--sbindirSystem administrative executablesEPREFIX/sbin
--sharedstatedirModifiable architecture-independent dataPREFIX/com
--srcdirFind the sources in DIRconfigure directory or ..
--sysconfdirRead-only single-machine dataPREFIX/etc
--targetConfigure for building compilers for TARGET
--versionDisplay version information and exit
--with-archive-storage-engineEnable the Archive Storage Engineno 5.1.9
--with-atomic-opsImplement atomic operations using pthread rwlocks or atomic CPU instructions for multi-processor 5.1.12
--with-berkeley-dbUse BerkeleyDB located in DIRno 5.1.11
--with-berkeley-db-includesFind Berkeley DB headers in DIR 5.1.11
--with-berkeley-db-libsFind Berkeley DB libraries in DIR 5.1.11
--with-big-tablesSupport tables with more than 4 G rows even on 32 bit platforms
--with-blackhole-storage-engineEnable the Blackhole Storage Engineno 5.1.9
--with-charsetDefault character set
--with-client-ldflagsExtra linking arguments for clients
--with-collationDefault collation
--with-commentComment about compilation environment
--with-csv-storage-engineEnable the CSV Storage Engineyes 5.1.9
--with-darwin-mwccUse Metrowerks CodeWarrior wrappers on OS X/Darwin
--with-debugAdd debug code (optionally with memory checker, very slow) 5.1.7
--with-embedded-privilege-controlBuild parts to check user's privileges (only affects embedded library)
--with-embedded-serverBuild the embedded server
--with-error-injectEnable error injection in MySQL Server 5.1.11
--with-example-storage-engineEnable the Example Storage Engineno 5.1.9
--with-extra-charsetsUse charsets in addition to default
--with-fast-mutexesCompile with fast mutexesdisabled5.1.5
--with-federated-storage-engineEnable federated storage engineno5.
--with-gnu-ldAssume the C compiler uses GNU ldno
--with-innodbEnable innobase storage engineno5.
--with-lib-ccflagsExtra CC options for libraries
--with-libwrapCompile in libwrap (tcp_wrappers) support
--with-low-memoryTry to use less memory to compile to avoid memory limitations
--with-machine-typeSet the machine type, like "powerpc"
--with-maria-temp-tablesMake the temporary tables within MySQL use the Maria storage engine 5.1.24
--with-max-indexesSets the maximum number of indexes per table64
--with-mysqld-ldflagsExtra linking arguments for mysqld
--with-mysqld-libsExtra libraries to link with for mysqld
--with-mysqld-userWhat user the mysqld daemon shall be run as
--with-mysqlmanagerBuild the mysqlmanager binaryBuild if server is built
--with-named-curses-libsUse specified curses libraries
--with-named-thread-libsUse specified thread libraries
--with-ndb-ccflagsExtra CC options for ndb compile
--with-ndb-docsInclude the NDB Cluster ndbapi and mgmapi documentation
--with-ndb-portPort for NDB Cluster management server
--with-ndb-port-basePort for NDB Cluster management server
--with-ndb-sciProvide MySQL with a custom location of sci library
--with-ndb-testInclude the NDB Cluster ndbapi test programs
--with-ndbclusterInclude the NDB Cluster table handlerno 5.1.9
--with-opensslInclude the OpenSSL support 5.1.9
--with-openssl-includesFind OpenSSL headers in DIR 5.1.9
--with-openssl-libsFind OpenSSL libraries in DIR 5.1.9
--with-other-libcLink against libc and other standard libraries installed in the specified nonstandard location
--with-picTry to use only PIC/non-PIC objectsUse both
--with-plugin-PLUGINForces the named plugin to be linked into mysqld statically 5.1.11
--with-pluginsPlugins to include in mysqldnone5.1.11
--with-pstackUse the pstack backtrace library 5.1.54
--with-pthreadForce use of pthread library
--with-row-based-replicationInclude row-based replication
--with-server-suffixAppend value to the version string
--with-sslInclude SSL support 5.1.11
--with-system-typeSet the system type, like "sun-solaris10"
--with-tagsInclude additional configurationsautomatic
--with-tcp-portWhich port to use for MySQL services3306
--with-unix-socket-pathWhere to put the unix-domain socket
--with-yasslInclude the yaSSL support 5.1.9
--with-zlib-dirProvide MySQL with a custom location of compression library
--without-PACKAGEDo not use PACKAGE
--without-benchSkip building of the benchmark suite 5.1.11
--without-debugBuild a production version without debugging code 5.1.6
--without-docsSkip building of the documentation
--without-extra-toolsSkip building utilities in the tools directory 5.1.9
--without-geometryDo not build geometry-related parts
--without-libeditUse system libedit instead of bundled copy
--without-manSkip building of the man pages
--without-ndb-binlogDisable ndb binlog 5.1.6
--without-ndb-debugDisable special ndb debug features
--without-plugin-PLUGINExclude PLUGIN 5.1.11
--without-query-cacheDo not build query cache
--without-readlineUse system readline instead of bundled copy
--without-row-based-replicationDon't include row-based replication
--without-serverOnly build the client
--without-ucaSkip building of the national Unicode collations

If you are using a version of gcc recent enough to understand the -fno-exceptions option, it is very important that you use this option. Otherwise, you may compile a binary that crashes randomly. Also use -felide-constructors and -fno-rtti along with -fno-exceptions. When in doubt, do the following:

CFLAGS="-O3" CXX=gcc CXXFLAGS="-O3 -felide-constructors \
       -fno-exceptions -fno-rtti" ./configure \
       --prefix=/usr/local/mysql --enable-assembler \

On most systems, this gives you a fast and stable binary.

When compiling from source, you should also be aware of any platform specific considerations that may influence and impact the build process. Knowing and applying this information will help to ensure you get the best performance and most stable binary for your chosen platform. For more information, use the following sections:

Some of the configure options available are described here. For options that may be of use if you have difficulties building MySQL, see Chapter 5, Dealing with Problems Compiling MySQL.

Many options configure compile-time defaults that can be overridden at server startup. For example, the --prefix, --with-tcp-port, and with-unix-socket-path 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.

  • To compile just the MySQL client libraries and client programs and not the server, use the --without-server option:

    shell> ./configure --without-server

    If you have no C++ compiler, some client programs such as mysql cannot be compiled because they require C++. In this case, you can remove the code in configure that tests for the C++ compiler and then run ./configure with the --without-server option. The compile step should still try to build all clients, but you can ignore any warnings about files such as (If make stops, try make -k to tell it to continue with the rest of the build even if errors occur.)

  • To build the embedded MySQL library (libmysqld.a), use the --with-embedded-server option.

  • To place your log files and database directories elsewhere than under /usr/local/var, use a configure command something like one of these:

    shell> ./configure --prefix=/usr/local/mysql
    shell> ./configure --prefix=/usr/local \

    The first command changes the installation prefix so that everything is installed under /usr/local/mysql rather than the default of /usr/local. The second command preserves the default installation prefix, but overrides the default location for database directories (normally /usr/local/var) and changes it to /usr/local/mysql/data.

    You can also specify the installation directory and data directory locations at server startup time by using the --basedir and --datadir options. These can be given on the command line or in an MySQL option file, although it is more common to use an option file. See Using Option Files.

  • The --with-tcp-port option specifies the port number on which the server listens for TCP/IP connections. The default is port 3306. To listen on a different port, use a configure command like this:

    shell> ./configure --with-tcp-port=3307
  • On Unix, if you want the MySQL socket file location to be somewhere other than the default location (normally in the directory /tmp or /var/run), use a configure command like this:

    shell> ./configure \

    The socket file name must be an absolute path name. You can also change the location of mysql.sock at server startup by using a MySQL option file. See How to Protect or Change the MySQL Unix Socket File.

  • To compile statically linked programs (for example, to make a binary distribution, to get better performance, or to work around problems with some Red Hat Linux distributions), run configure like this:

    shell> ./configure --with-client-ldflags=-all-static \
  • If you are using gcc and do not have libg++ or libstdc++ installed, you can tell configure to use gcc as your C++ compiler:

    shell> CC=gcc CXX=gcc ./configure

    When you use gcc as your C++ compiler, it does not attempt to link in libg++ or libstdc++. This may be a good thing to do even if you have those libraries installed. Some versions of them have caused strange problems for MySQL users in the past.

    In most cases, you can get a reasonably optimized MySQL binary by using the following options on the configure line:

    --prefix=/usr/local/mysql --enable-assembler \

    The full configure line would, in other words, be something like the following for all recent gcc versions:

    CFLAGS="-O3 -mpentiumpro" CXX=gcc CXXFLAGS="-O3 -mpentiumpro \
    -felide-constructors -fno-exceptions -fno-rtti" ./configure \
    --prefix=/usr/local/mysql --enable-assembler \

    The binaries we provide on the MySQL Web site at are all compiled with full optimization and should work well for most users. See Installing MySQL on Unix/Linux Using Generic Binaries.

  • If the build fails and produces errors about your compiler or linker not being able to create the shared library (where N is a version number), you can work around this problem by giving the --disable-shared option to configure. In this case, configure does not build a shared library.

  • By default, MySQL uses the latin1 (cp1252 West European) character set. To change the default set, use the --with-charset option:

    shell> ./configure --with-charset=CHARSET

    CHARSET 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. (Additional character sets might be available. Check the output from ./configure --help for the current list.)

    The default collation may also be specified. MySQL uses the latin1_swedish_ci collation by default. To change this, use the --with-collation option:

    shell> ./configure --with-collation=COLLATION

    To change both the character set and the collation, use both the --with-charset and --with-collation options. The collation must be a legal collation for the character set. (Use the SHOW COLLATION statement to determine which collations are available for each character set.)

    With the configure option --with-extra-charsets=LIST, you can define which additional character sets should be compiled into the server. LIST is one of the following:

    • A list of character set names separated by spaces

    • complex to include all character sets that can't be dynamically loaded

    • all to include all character sets into the binaries

    Clients that want to convert characters between the server and the client should use the SET NAMES statement. See Connection Character Sets and Collations.

  • To configure MySQL with debugging code, use the --with-debug option:

    shell> ./configure --with-debug

    This causes a safe memory allocator to be included that can find some errors and that provides output about what is happening. See Debugging and Porting MySQL.

    As of MySQL 5.1.12, using --with-debug to configure 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.

  • To cause the Debug Sync facility to be compiled into the server, use the --enable-debug-sync option. This facility is used for testing and debugging. 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.

    Debug Sync is also compiled in if you configure with the --with-debug option (which implies --enable-debug-sync), unless you also use the --disable-debug-sync option.

    For a description of the Debug Sync facility and how to use synchronization points, see MySQL Internals: Test Synchronization.

    The --enable-debug-sync and --disable-debug-sync options were added in MySQL 5.1.41.

  • If your client programs are using threads, you must compile a thread-safe version of the MySQL client library with the --enable-thread-safe-client configure option. This creates a libmysqlclient_r library with which you should link your threaded applications. See Writing C API Threaded Client Programs.

  • 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-dir=no|bundled|DIR option provides control over compression library support. The value no explicitly disables compression support. bundled causes the zlib library bundled in the MySQL sources to be used. A DIR path name specifies the directory in which to find the compression library sources.

  • It is possible to build MySQL with large table support using the --with-big-tables option.

    This option causes the variables that store table row counts to be declared as unsigned long long rather than unsigned long. This enables tables to hold up to approximately 1.844E+19 ((232)2) rows rather than 232 (~4.295E+09) rows. Previously it was necessary to pass -DBIG_TABLES to the compiler manually in order to enable this feature.

  • Run configure with the --disable-grant-options option to cause the --bootstrap, --skip-grant-tables, and --init-file options for mysqld to be disabled. For Windows, the configure.js script recognizes the DISABLE_GRANT_OPTIONS flag, which has the same effect. The capability is available as of MySQL 5.1.15.

  • This option allows MySQL Community Server features to be enabled. Additional options may be required for individual features, such as --enable-profiling to enable statement profiling. This option was added in MySQL 5.1.24. It is enabled by default as of MySQL 5.1.28; to disable it, use --disable-community-features.

  • When given with --enable-community-features, the --enable-profiling option enables the statement profiling capability exposed by the SHOW PROFILE and SHOW PROFILES statements. (See SHOW PROFILES Syntax.) This option was added in MySQL 5.1.24. It is enabled by default as of MySQL 5.1.28; to disable it, use --disable-profiling.

  • See General Installation Guidance, for options that pertain to particular operating systems.

  • See Building MySQL with SSL Support, for options that pertain to configuring MySQL to support secure (encrypted) connections.

  • Several configure options apply to plugin selection and building:


    PLUGIN is an individual plugin name such as csv or archive.

    As shorthand, GROUP is a configuration group name such as none (select no plugins) or all (select all plugins).

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

    configure --help shows the following information pertaining to plugins:

    • The plugin-related options

    • The names of all available plugins

    • For each plugin, a description of its purpose, which build types it supports (static or dynamic), and which plugin groups it is a part of.

    --with-plugins can take a list of one or more plugin names separated by commas, or a plugin group name. The named plugins are configured to be built as static plugins.

    --with-plugin-PLUGIN configures the given plugin to be built as a static plugin.

    --without-plugin-PLUGIN disables the given plugin from being built.

    If a plugin is named both with a --with and --without option, the result is undefined.

    For any plugin that is not explicitly selected or disabled, it is selected to be built dynamically if it supports dynamic build, and not built if it does not support dynamic build. (Thus, in the case that no plugin options are given, all plugins that support dynamic build are selected to be built as dynamic plugins. Plugins that do not support dynamic build are not built.)

Download this Excerpt
PDF (US Ltr) - 279.8Kb
PDF (A4) - 280.2Kb
EPUB - 97.2Kb
HTML Download (TGZ) - 63.4Kb
HTML Download (Zip) - 79.7Kb
User Comments
Sign Up Login You must be logged in to post a comment.