I’ve got an upcoming post that discusses the steps for compilingfrom source. Before I get to that topic, though, I thought a preliminary post on the reasons for doing so would be helpful.
Almost everydatabase project provides an installer for various platforms. Why then would you bother to compile MySQL (or any other database)? There are number of good reasons.
- You have an opportunity to read the code
If you have the time and inclination, grabbing and compiling the source code is the perfect excuse to spend some time reading the code, particularly the parts of the code that interest you. How exactly does PostgreSQL implement k-nearest-neighbor indexing (new in version 9.1)?
Sometimes the source code is installed along with binary versions when you use an installer, but this is often not the case. If you download the source to compile it, you know you’ll have it available to read at your leisure.
- Some options are only available by compiling the source
You might want to try out an atypical storage engine, but you can only do that by mixing in support for that engine when you compile the code itself. For example, you want to use the FEDERATED engine in MySQL, but that doesn’t come as part of the installer-produced installation. You really have no choice but to compile MySQL and include support for the FEDERATED engine as part of the configure-and-compile process.
- You can more easily set some defaults
You might not care for the default database character set. Sometimes DBAs or developers forget to set a character set when creating a table. For those times, you may want to enforce a standard that all database tables use the UTF-8 character set (unless specifically overridden). When configuring MySQL for compilation use the -DDEFAULT_CHARSET=utf8 command line option.
- You want to get an up-to-date version, including the latest patches
Want the latest and greatest version of the server, including the most recently committed changes for bugs and security holes? No problem! Just download and compile the most current source, and you will automatically get the latest bug fixes and security patches.
In future posts, I’ll discuss the steps for compiling MySQL and PostgreSQL from source code.