intro
For many, the process of compiling MySQL is the source of headaches. It doesn’t have to be that way — read this blog and you will understand that building MySQL from source isn’t that hard after all!
There are various ways to use MySQL. For many of us, methods to install and use MySQL vary from the operating system(s) in question — most of the development environments for programmers will be Linux-based while many demo environments will be based on Windows. However, before we even consider our MySQL instances to be usable, our database instances must be installed and set up properly. Here’s how to compile MySQL from source static!
Why Compile MySQL from the Source?
Developers have multiple ways to use MySQL and related database management systems but those that opt to compile MySQL from source static do so because of one or more of the following reasons:
Of course, everything’s done within limits and MySQL is indeed very vocal about those — at the same time, for those that compile MySQL from the source code, MySQL does provide everyone with an INFO_BIN
file that contains information about how MySQL is to be configured, compiled, and/or distributed.
How to Compile MySQL from the Source?
So, how exactly do you compile MySQL from source static code? MySQL notes that there are two ways to accomplish this task. We can do this by either:
In other words, we can either configure, build, and install MySQL by downloading it as a source distribution, unzipping it and installing it on our PC or clone a git repository and compile MySQL from source static that way. Here’s how everything looks like.
Installing MySQL Using a Standard MySQL Source Distribution
To install MySQL in the “vanilla” way, we first need to verify that our system(s) in question conform with the prerequisites outlined by MySQL themselves. We can do that by checking out the prerequisites in the documentation that may change as MySQL evolves, however, the standard minimum requirements are as follows:
Once that’s done, we need to setup a mysql
user — this user will own database directories and will be used to run MySQL Server in and of itself. Then, unzip the MySQL distribution you have on file and fiddle with its configuration:
Step 1: Install the necessary dependencies for MySQL.
Step 2: Configure the MySQL Server build by using cmake
and specifying your options after creating a directory:
1
mkdir build # creating a build directory
2
cd build # navigating into the directory
3
cmake .. [your_options] # configuring the MySQL Server build
Step 3: Compile MySQL Server by using a make
command, then install MySQL by issuing sudo make install
.
Step 4: Verify that MySQL Server has been installed by running /path/to/mysqld --version
(replace /path/to/mysqld
with the path towards the MySQL daemon.)
Step 5: Configure MySQL. Setup the mysql user, the base directory, and the data directory as well:
sudo /usr/local/mysql/bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
Step 6: Start MySQL Server “on a loop” by issuing something akin to sudo /path/to/mysqld_safe --user=mysql &
(replate the /path/to/mysqld_safe
with the actual path and don’t forget the &
at the end — it makes MySQL be able to be up and running without you re-running the command.)
Step 7: Perform post-installation setup and testing if necessary — in many cases, this will involve fiddling with the my.cnf
or my.ini
file, creating databases, tables, indexes, and partitions within them, and other things.
Installing MySQL Using a Development Source Tree
To install MySQL using a development source tree, first clone MySQL onto your server:
Things to Note
The compile MySQL from source static process may seem a little daunting, and that’s why you need to understand why you do the things you do:
Summary
The compile MySQL from source static process may seem daunting at first, but once you understand the intricacies behind it, everything falls into their own places. We hope that this blog has helped you understand why certain steps in the compiling process are necessary and we hope to see you around in some of our upcoming blogs. For now, make sure to follow our blog through TheTable, and until next time.
FAQ
What does compile MySQL from source static method refer to?
The compile MySQL from source static method refers to developers building MySQL “from the ground up” and modifying the parameters or libraries in the process.
Where can I learn more about MySQL and other DBMS?
To learn more about MySQL and other database management systems, read the documentation, blogs, books on MySQL, and don’t forget to attend conferences to network with professionals in your field. Reading books like “Hacking MySQL: Breaking, Optimizing, and Securing MySQL for Your Use Case” will be a good place to start and reading blogs like TheTable will also be a great place if you want to expand your existing knowledge.
Why should I use DbVisualizer Pro?
Consider using the Pro version of DbVisualizer because the Pro version of DbVisualizer will allow you to export data in various formats, edit data as if it were a spreadsheet, view XML data in a tree or text formats, it will come with an SQL formatter with extensive customization options, and provide you with various other ways to solve database-related issues and problems. Try DbVisualizer Pro today!