redhat7.4下编译运行mysql源码

STEP-1:环境准备

  • MySQL-8.0.20的编译依赖gcc-5.3+/cmake3.5.2+
  • gcc-5.3依赖库gmp/mpfc/mpc

安装动态库版本如下:

  (1) gmp-6.1.0

  (2) mpfr-3.1.4

  (3) mpc-1.0.3

 

库源码下载地址:

  ftp://gcc.gnu.org/pub/gcc/infrastructure/

 

依赖库编译安装步骤:

  解压下载的库源码,进入到相应目录内分别执行:

 ./configure --prefix=/usr/local/gmp-6.1.0
 ./configure --prefix=/usr/local/mpfr-3.1.4 --with-gmp=/usr/local/gmp-6.1.0
 ./configure --prefix=/usr/local/mpc-1.0.3 --with-gmp=/usr/local/gmp-6.1.0 --with-mpfr=/usr/local/mpfr-3.1.4

 

编译gcc-5.3(此过程会比较久):

 ./configure --prefix=/usr/local/gcc-5.3.0 --build=x86_64-linux -enable-threads=posix -disable-checking -disable-multilib -enable-languages=c,c++ --with-gmp=/usr/local/gmp-6.1.0 --with-mpfr=/usr/local/mpfr-3.1.4/ --with-mpc=/usr/local/mpc-1.0.3/

 

cmake编译

   ./bootstrap

  gmake

  gmake install

 

环境变量设置:

  在/etc/profile最后添加:

    export PATH=/usr/local/gcc-5.3.0/bin:/$PATH
    export LD_LIBRARY_PATH=gmp-6.1.0/lib:mpc-1.0.3/lib:mpfr-3.1.4/lib:/usr/local/gcc-5.3.0/lib64:$LD_LIBRARY_PATH

 然后执行 source /etc/profile

 

 

STEP-2:MySQL-8.0.20源码编译

1. execute cmake

cmake -DCMAKE_INSTALL_PREFIX=/home/mysql_build -DMYSQL_DATADIR=/home/mysql_build/data/data -DSYSCONFDIR=/home/mysql_build/etc -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DMYSQL_UNIX_ADDR=/home/mysql_build/bin/mysql.sock -DMYSQL_TCP_PORT=6303 -DENABLED_LOCAL_INFILE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8mb4 -DDEFAULT_COLLATION=utf8mb4_general_ci -DWITH_BOOST=/usr/local/boost -DWITH_DEBUG=1

2. make && make install

3. mkdir ./etc && cp /home/mysql_1/etc/my.cnf ./etc/

4. mkdir -p ~/data/data && mkdir -p ~/data/binlog && mkdir -p ~/data/relaylog

5. ./bin/mysqld --initialize-insecure --datadir=/home/mysql_build/data/data --basedir=/home/mysql_build

6. add skip-grant-tables to my.cnf

7. ./bin/mysqld --defaults-file=~/etc/my.cnf &

8. connect db with network: mysql -uroot -h192.168.0.156 -P6303

9. update user set Host="%", authentication_string=password("123456") where User='root';

10. flush privileges;

11. remove skip-grant-tables from my.cnf

12. start mysql again and try to connect db with passwd: mysql -uroot -h192.168.0.156 -P6303 -p'123456'

posted @ 2019-05-19 20:03  Xinxin_Brian  阅读(155)  评论(0编辑  收藏  举报