MySQL Source Compiling for debugging

I’ve been evaluating MySQL 8.0 for a while and thought to share quick steps to compile the source code for debugging. The steps I’ve shared are for Centos 7 x86_64 platform(or similar)

1. Download the latest MySQL Source


wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-community-8.0.3-0.1.rc.el7.src.rpm

2. You might need packages generally not found in by default in Linux Distributions

rpm-build.x86_64
devtoolset-6-runtime-6.1-1
devtoolset-6-binutils-2.27-12
devtoolset-6-gcc-6.3.1-3.1
devtoolset-6-libstdc++-devel-6.3.1-3.1
devtoolset-6-gcc-c++-6.3.1-3.1
cmake
perl(Env)
libaio-devel
ncurses-devel
openssl-devel
numactl-devel
cyrus-sasl-devel

3.  Open the rpm package in desired folder


rpm2cpio mysql-community-8.0.3-0.1.rc.el7.src.rpm | cpio -idmv
boost_1_64_0.tar.bz2
filter-provides.sh
filter-requires.sh
mysql-5.6.37.tar.gz
mysql-8.0.3-rc.tar.gz
mysql.spec

#Open the source zip/tar file

tar -xzvf mysql-8.0.3-rc.tar.gz

#Open boost zip/tar file

tar -xjvf boost_1_64_0.tar.bz2

#Change dir to mysql-8.0.3-rc

cd mysql-8.0.3-rc

4. Compile with debug


cmake -DWITH_DEBUG=1 -DDOWNLOAD_BOOST=1 -DWITH_BOOST=mysql-8.0.3-rc/boost_1_64_0/boost
make
make install
ln -s /usr/local/mysql/bin/* /usr/bin/

5. Make symlink and create user


ln -s /usr/local/mysql/bin/* /usr/bin/
groupadd mysql
useradd -r -g mysql -s /bin/false mysql

It couldn’t be that simpler right…. Well it is. Have fun with MySQL ….