Compiling mysql 5.7 source code with centos7

First, you need to execute according to the compiled documents of mysql. mysql document

  1. What do you need?

    1. cmake Official website

      Compilation and installation script of cmake
      	tar zxvf cmake-3.16.5.tar.gz
      	cd cmake-3.16.5
      	./bootstrap --prefix=/usr/local
      	make -j4
      	make install
    2. make program Official website

      The version needs to be higher than 3.75, which can be viewed through make --version
    3. Compiler Version

      The compiler needed for compilation needs to support at least C++14 GCC 5.3 (Linux) Clang 4.0 (FreeBSD) XCode 9 (macOS) Developer Studio 12.6 (Solaris) Visual Studio 2017 (Windows)

    4. API of mysql C

      Compiler c + + or C99 required
    5. open ssl Library

      A SSL Library
      	yum install openssl-devel
      	sudo apt-get install libssl-dev
      	#mac os
      	brew install openssl
    6. boost library Official website

      Generally, when downloading the source code, you will bring it with you, and the corresponding boost libraries of different versions may be different It needs to be used to compile mysql, but it is not generally used. When cmake, you need to declare the location of the boost library

      	cmake . -DWITH_BOOST=/usr/local/boost_version_number
      When downloading mysql, it is better to download the version with the corresponding boost library.
      	cmake . -DWITH_BOOST=/root/mysql-5.7.29/boost
    7. ncurses Library Official website

      	sudo yum install ncurses-devel
      	# ubuntu
      	sudo apt-get install libncurses5-dev libncursesw5-dev
    8. Enough free space

    9. Optional test tool Perl

    Full version

    	# Preconfiguration setup
    	shell> groupadd mysql
    	shell> useradd -r -g mysql -s /bin/false mysql
    	# Beginning of source-build specific instructions
    	shell> tar zxvf mysql-VERSION.tar.gz
    	shell> cd mysql-VERSION
    	shell> mkdir bld
    	shell> cd bld
    	shell> cmake ..
    	shell> make
    	shell> make install
    	# End of source-build specific instructions
    	# Postinstallation setup
    	shell> cd /usr/local/mysql
    	shell> mkdir mysql-files
    	shell> chown mysql:mysql mysql-files
    	shell> chmod 750 mysql-files
    	shell> bin/mysqld --initialize --user=mysql
    	shell> bin/mysql_ssl_rsa_setup
    	shell> bin/mysqld_safe --user=mysql &
    	# Next command is optional
    	shell> cp support-files/mysql.server /etc/init.d/mysql.server
  2. Switch GCC version to 7

    	sudo yum install centos-release-scl
    	sudo yum install devtoolset-7
    	scl enable devtoolset-7 bash
    	gcc --version

Tags: MySQL shell cmake sudo

Posted on Thu, 19 Mar 2020 10:13:06 -0400 by Angerslave