51ak show you MYSQL5.7 source 2: compiling existing code

Years of DBA experience

MYSQL source code is also the first contact

Try to record the course of looking at MYSQL5.7 source code

 

Catalog:

51ak show you the MYSQL5.7 source 1: main entry function

51ak show you MYSQL5.7 source 2: compiling existing code

 

Now install the source code you saw in VSCODE as a service.

 

Tester: CENTOS6 (virtual machine configuration is 4c+4g),

YUM installation related components

 yum -y install gcc-c++ ncurses-devel cmake make perl gcc autoconf automake zlib libxml libgcrypt libtool bison

After execution, check the existing BOOTST version. If there is any deletion

root@wjz-3-227 ~]# rpm -qa boost*
boost-filesystem-1.41.0-18.el6.x86_64
boost-system-1.41.0-18.el6.x86_64
[root@wjz-3-227 ~]#  yum -y remove boost-*
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Remove Process
Resolving Dependencies
--> Running transaction check

 

Upload the edited file to the tester and put it in the / work directory

Copy and install BOOST

root@wjz-3-227 mysql-server]# ll
total 108
drwxr-xr-x.  8 root root  4096 Mar 22  2018 boost_1_59_0
-rw-r--r--.  1 root root   160 Dec 28 12:00 filter-provides.sh
-rw-r--r--.  1 root root   176 Dec 28 12:00 filter-requires.sh
drwxr-xr-x. 32 root root  4096 Mar 22  2018 mysql-5.1.72
drwxr-xr-x. 35 root root  4096 Mar 22  2018 mysql-5.7.21
-rw-r--r--.  1 root root 88859 Dec 28 12:00 mysql.spec
[root@wjz-3-227 mysql-server]# cp -r  boost_1_59_0 /usr/local/boost

 

Execute the following script

groupadd mysql
mkdir /home/mysql
mkdir /home/mysql/data
useradd mysql -g mysql -d /home/mysql

cd mysql-5.7.21/
mkdir debug
cd debug

Start MAKE

cmake .. \
-DCMAKE_INSTALL_PREFIX=/home/mysql  \
-DMYSQL_DATADIR=/home/mysql/data \
-DDEFAULT_CHARSET=utf8  \
-DDEFAULT_COLLATION=utf8_general_ci \
-DMYSQL_TCP_PORT=3306 \
-DMYSQL_USER=mysql  \
-DWITH_MYISAM_STORAGE_ENGINE=1  \
-DWITH_INNOBASE_STORAGE_ENGINE=1  \
-DWITH_ARCHIVE_STORAGE_ENGINE=1  \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1  \
-DDOWNLOAD_BOOST=1  \
-DWITH_BOOST=/usr/local/boost

The following figure shows success.

 

 make -j 4 

Long wait, compilation successful (tester performance too many times)

 

Install and initialize as follows:

make install 
make clean 
rm -f CMakeCache.txt 
cd /home/mysql
chown -R mysql:mysql .
ll
 bin/mysqld --initialize --user=mysql --basedir=/home/mysql --datadir=/home/mysql/data #Remember the generated password in this step,I'll use it later.
ll data/
vim /etc/my.cnf 
vim mysql.server 
cp mysql.server  /etc/init.d/mysqld3306
chmod 755 /etc/init.d/mysqld3306 
cd ..
ll
service mysqld3306 start
bin/mysql -h127.0.0.1 -uroot -p

 

Only this and nothing more

Tags: MySQL yum cmake vim

Posted on Fri, 03 Apr 2020 16:22:45 -0700 by eroticheretic