MySQL 源码编译安装步骤
---------------------------------------cmake---------------------------------------
--cmake
[root@localhost mysql_5.7.32_source]# mkdir bld
[root@localhost mysql_5.7.32_source]# cd bld
[root@localhost bld]# pwd
/usr/local/mysql_5.7.32_source/bld
[root@localhost bld]# ls
[root@localhost bld]# cmake ../mysql-5.7.32/
-- Running cmake version 2.8.12.2
-- Found Git: /usr/bin/git (found version "1.8.3.1")
-- Configuring with MAX_INDEXES = 64U
-- The C compiler identification is GNU 4.8.5
-- The CXX compiler identification is GNU 4.8.5
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- CMAKE_GENERATOR: Unix Makefiles
-- Looking for SHM_HUGETLB
-- Looking for SHM_HUGETLB - found
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of void *
-- Check size of void * - done
-- SIZEOF_VOIDP 8
-- Performing Test HAVE_C_SHIFT_OR_OPTIMIZATION_BUG
-- Performing Test HAVE_C_SHIFT_OR_OPTIMIZATION_BUG - Failed
-- Performing Test HAVE_CXX_SHIFT_OR_OPTIMIZATION_BUG
-- Performing Test HAVE_CXX_SHIFT_OR_OPTIMIZATION_BUG - Failed
-- Performing Test HAVE_C_FLOATING_POINT_FUSED_MADD
-- Performing Test HAVE_C_FLOATING_POINT_FUSED_MADD - Failed
-- Performing Test HAVE_CXX_FLOATING_POINT_FUSED_MADD
-- Performing Test HAVE_CXX_FLOATING_POINT_FUSED_MADD - Failed
-- Performing Test HAVE_C_FP_CONTRACT_FLAG
-- Performing Test HAVE_C_FP_CONTRACT_FLAG - Success
-- Performing Test HAVE_CXX_FP_CONTRACT_FLAG
-- Performing Test HAVE_CXX_FP_CONTRACT_FLAG - Success
-- MySQL 5.7.32
-- Packaging as: mysql-5.7.32-Linux-x86_64
-- Looked for boost/version.hpp in and
-- BOOST_INCLUDE_DIR BOOST_INCLUDE_DIR-NOTFOUND
-- LOCAL_BOOST_DIR
-- LOCAL_BOOST_ZIP
-- Could not find (the correct version of) boost.
-- MySQL currently requires boost_1_59_0
CMake Error at cmake/boost.cmake:88 (MESSAGE):
You can download it with -DDOWNLOAD_BOOST=1 -DWITH_BOOST=<directory>
This CMake script will look for boost in <directory>. If it is not there,
it will download and unpack it (in that directory) for you.
If you are inside a firewall, you may need to use an http proxy:
export http_proxy=http://example.com:80
Call Stack (most recent call first):
cmake/boost.cmake:245 (COULD_NOT_FIND_BOOST)
CMakeLists.txt:548 (INCLUDE)
-- Configuring incomplete, errors occurred!
See also "/usr/local/mysql_5.7.32_source/bld/CMakeFiles/CMakeOutput.log".
See also "/usr/local/mysql_5.7.32_source/bld/CMakeFiles/CMakeError.log".
[root@localhost bld]#
缺少boost,cmake失败
--cmake 加上boost库目录
cmake ../mysql-5.7.32/ -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/usr/local/mysql_5.7.32_source/mysql-5.7.32/boost
-- Configuring done
-- Generating done
-- Build files have been written to: /usr/local/mysql_5.7.32_source/bld
[root@localhost bld]#
-----------------------------------make-----------------------------
make
make VERBOSE=1
/usr/bin/cmake -E cmake_progress_report /usr/local/mysql_5.7.32_source/bld/CMakeFiles
[100%] Built target my_safe_process
make[1]: Leaving directory `/usr/local/mysql_5.7.32_source/bld'
/usr/bin/cmake -E cmake_progress_start /usr/local/mysql_5.7.32_source/bld/CMakeFiles 0
[root@localhost bld]#
------------------------------make install -------------------------------
--默认安装到 /usr/local/mysql
make install
--安装到指定的目录
make install DESTDIR="/opt/mysql"
--生成一个 .tar.gz的二进制安装文件
make package
make install DESTDIR='/home/mysql'
-- Installing: /home/mysql/usr/local/mysql/mysql-test/lib/My/SafeProcess/my_safe_process
-- Up-to-date: /home/mysql/usr/local/mysql/mysql-test/lib/My/SafeProcess/my_safe_process
-- Installing: /home/mysql/usr/local/mysql/mysql-test/lib/My/SafeProcess/Base.pm
-- Installing: /home/mysql/usr/local/mysql/support-files/mysqld_multi.server
-- Installing: /home/mysql/usr/local/mysql/support-files/mysql-log-rotate
-- Installing: /home/mysql/usr/local/mysql/support-files/magic
-- Installing: /home/mysql/usr/local/mysql/share/aclocal/mysql.m4
-- Installing: /home/mysql/usr/local/mysql/support-files/mysql.server
[root@localhost bld]#
-------------初始化数据库------------
./mysqld --initialize --user=mysql --datadir=/usr/local/my3306
2021-09-26T21:08:07.686295Z 1 [Note] A temporary password is generated for root@localhost: >tzygejht1:C
-----------------启动数据库---------------------------------
[mysqld]
basedir = /home/mysql/usr/local/mysql
datadir = /usr/local/my3306
port = 3306
socket=/tmp/my3306.sock
character-set-server=utf8mb4
default_storage_engine = InnoDB
./mysqld_safe --defaults-file=/usr/local/my3306/my3306.cnf --user=mysql &