Revision
8521
User
dbart
Date
2011-11-08 15:59
The instructions on this page will help you compile [[MariaDB]] from source. Links to more complete instructions for specific platforms can be found on the [[source]] page. First, [[Getting the MariaDB Source Code|get a copy of the MariaDB source]]. Next, prepare your system to be able to compile the source. An easy way to do this if you use Linux is to run one of the following commands (depending on your Linux distribution): <<code lang=sh>> sudo apt-get build-dep mysql-server # for Debian and Ubuntu-based distributions sudo yum-builddep mysql # for Fedora sudo zypper si -d mysql-community-server # for OpenSUSE <</code>> <<style class="bluebox" style="font-size:0.8em;">> Note: On Debian-based distributions, you may receive a //"You must put some 'source' URIs in your sources.list"// error. To avoid this, ensure that /etc/apt/sources.list contains the source repositories.\\ \\ For Debain Squeeze: <<code lang=sh>> deb http://ftp.debian.org/debian squeeze main contrib deb http://security.debian.org squeeze/updates main contrib deb-src http://ftp.debian.org/debian squeeze main contrib deb-src http://security.debian.org squeeze/updates main contrib <</code>> Refer to the documentation for your Linux distribution for how to do this on your system.\\ \\ After editing the sources.list, do: <<code lang=sh inline=false>> sudo apt-get update <</code>> ...and then the above mentioned ##build-dep## command. <</style>> <<style class="greenbox" style="font-size:0.8em;">> Note: On openSUSE the source package repository may be disabled. The following command will enable it: <<code lang=sh inline=false>> sudo zypper mr -er repo-source <</code>> After enabling it, you will be able to run the zypper command to install the build dependencies. <</style>> If you don't want to run MariaDB as yourself, then you should create a ##mysql## user. The example below uses this user. Now cd into the source directory and execute the appropriate BUILD script that matches your configuration: <<code lang=sh inline=false>> cd $maria-source-dir # ex: ~/repos/maria/trunk BUILD/compile-pentium64-max # Build for intel/amd 64 bit with all options BUILD/compile-pentium-max # Build for 32 bit pentum with all options BUILD/compile-pentium64-debug-max # Build for intel/amd 64 bit with debugging BUILD/compile-pentium64-valgrind-max # Build for testing with valgrind <</code>> To see what a build scripts does, you can run it with the <<code>>--print<</code>> option. If there is no appropriate script, you can also execute <<code>>configure<</code>> directly: <<code lang=sh inline=false>> cd $maria-source-dir # ex: ~/repos/maria/trunk BUILD/autorun.sh ./configure --with-plugin-xtradb make sudo make install <</code>> == Starting MariaDB for the first time Prior to starting MariaDB for the first time: # ensure the directory is owned by the mysql user (if the user doesn't exist, you'll need to create it) # run the ##mysql_install_db## script to generate the needed system tables Here is an example: <<code lang=sh inline=false>> # The following assumes that the 'mysql' user exists and that we installed MariaDB # in /usr/local/mysql chown -R mysql /usr/local/mysql/ scripts/mysql_install_db --user=mysql /usr/local/mysql/bin/mysqld_safe --user=mysql & <</code>> == Max builds configure line The following configure line is the one we use in the -max builds (which includes all features we think are relevant). This is also the configure line we use with most of our binary builds: <<code>> ./configure --prefix=/usr/local/mysql --enable-assembler \ --with-extra-charsets=complex --enable-thread-safe-client --with-big-tables \ --with-plugin-maria --with-aria-tmp-tables --without-plugin-innodb_plugin \ --with-mysqld-ldflags=-static --with-client-ldflags=-static --with-readline \ --with-ssl --with-plugins=max-no-ndb --with-embedded-server --with-libevent \ --with-mysqld-ldflags=-all-static --with-client-ldflags=-all-static \ --with-zlib-dir=bundled --enable-local-infile <</code>> For a full list of options, you can do: <<code>> configure --help <</code>> If you want to test your compiled MariaDB, you can do either of: <<code>> make test <</code>> <<code>> cd mysql-test ; mysql-test-run --force <</code>> **NOTE:** If you are testing or debugging MariaDB you may want to run it from where you have the source code instead of installing it with 'make install'. If so, see the [[running-mariadb-from-the-source-directory|Running MariaDB from the Source Directory]] page. == Post-Install tasks * [[installing-system-tables-mysql_install_db|Installing system tables (mysql_install_db)]] * [[starting-and-stopping-mariadb-automatically|Starting and Stopping MariaDB Automatically]]