MySQL 5.7.10最新版本源代码安装详细过程

MySQL 5.7.10最新版本源代码安装详细过程

1,下载地址:
安装包下载地址:

可以wget下载,也可以在pc本地网页上下载完再远程传到linux上面去。

安装文档地址:

文档干货在这里:

# Preconfiguration setup

shell> groupadd mysql

shell> useradd -r -gmysql -s /bin/false mysql

# Beginning of source-build specificinstructions

shell> tar zxvf mysql-VERSION.tar.gz

shell> cd mysql-VERSION

shell> cmake .

shell> make

shell> make install

# End of source-build specific instructions

# Postinstallation setup

shell> cd/usr/local/mysql

shell> chown -R mysql .

shell> chgrp -R mysql .

shell> bin/mysql_install_db--user=mysql    # Before MySQL 5.7.6

shell> bin/mysqld--initialize --user=mysql # MySQL 5.7.6 and up

shell> bin/mysql_ssl_rsa_setup              # MySQL 5.7.6 and up

shell> chown -R root .

shell> chown -R mysqldata

shell> bin/mysqld_safe--user=mysql &

# Next command is optional

shell> cpsupport-files/mysql.server /etc/init.d/mysql.server

PS:看到差别在于,bin/mysqld--initialize --user=mysql # MySQL 5.7.6 and up

2,添加mysql用户
groupadd mysql         
useradd -g mysql mysql         
autoreconf --force --install
libtoolize --automake --force
automake --force --add-missing

3,安装组件准备
yum install gcc gcc-c++ -y
yum install -y ncurses-devel.x86_64
yum install -y cmake.x86_64
yum install -y libaio.x86_64
yum install -y bison.x86_64
yum install -y gcc-c++.x86_64

4,数据库规划
mysql软件目录  : /usr/local/mysql5710

mysql数据目录:/home/data/mysql5710/data/

mysql日志目录:/home/data/mysql5710/log/


mkdir -p /home/data/mysql5710/data
mkdir -p /usr/local/mysql5710

mkdir -p/home/data/mysql5710/log/

5,开始预编译
 time cmake .-DCMAKE_INSTALL_PREFIX=/usr/local/mysql5710 -DMYSQL_DATADIR=/home/data/mysql5710/data-DWITH_INNOBASE_STORAGE_ENGINE=1 -DMYSQL_UNIX_ADDR==/usr/local/mysql5710/mysql.sock-DMYSQL_USER=mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci

有报错信息:

CMake Error at cmake/boost.cmake:76(MESSAGE):

Youcan download it with -DDOWNLOAD_BOOST=1 -DWITH_BOOST=<directory>

This CMake script will look for boost in <directory>.  If it is not there,

itwill download and unpack it (in that directory) for you.

Ifyou are inside a firewall, you may need to use an http proxy:

添加参数-DDOWNLOAD_BOOST=1 -DWITH_BOOST=/home/mysql5710/,继续编译:

time cmake .-DCMAKE_INSTALL_PREFIX=/usr/local/mysql5710-DMYSQL_DATADIR=/home/data/mysql5710/data -DWITH_INNOBASE_STORAGE_ENGINE=1-DMYSQL_UNIX_ADDR==/usr/local/mysql5710/mysql.sock -DMYSQL_USER=mysql-DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DDOWNLOAD_BOOST=1-DWITH_BOOST=/usr/local/boost/

看到报错信息:

-- [download 31% complete]

-- Download failed, error: 28;"Timeoutwas reached"

CMake Error at cmake/boost.cmake:177(MESSAGE):

Youcan try downloading

manually using curl/wget or a similar tool, or increase the value of

DOWNLOAD_BOOST_TIMEOUT (which is now 600 seconds)

Call Stack (most recent call first):

CMakeLists.txt:435 (INCLUDE)

-- Configuring incomplete, errors occurred!

然后再继续,设置一个DOWNLOAD_BOOST_TIMEOUT=28800来继续下载:

[root@linuxidc mysql-5.7.10]# timecmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql5710-DMYSQL_DATADIR=/home/data/mysql5710/data -DWITH_INNOBASE_STORAGE_ENGINE=1-DMYSQL_UNIX_ADDR==/usr/local/mysql5710/mysql.sock -DMYSQL_USER=mysql-DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DDOWNLOAD_BOOST=1-DWITH_BOOST=/usr/local/boost/ -DOWNLOAD_BOOST_TIMEOUT=28800

也不行,报一样的错误,看来还是需要手动下载了

mkdir -p /usr/local/boost

wget

然后继续编译:

time cmake .-DCMAKE_INSTALL_PREFIX=/usr/local/mysql5710-DMYSQL_DATADIR=/home/data/mysql5710/data -DWITH_INNOBASE_STORAGE_ENGINE=1-DMYSQL_UNIX_ADDR==/usr/local/mysql5710/mysql.sock -DMYSQL_USER=mysql-DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci  -DWITH_BOOST=/usr/local/boost/

最好出现如下信息表示编译通过:

……

-- CMAKE_BUILD_TYPE: RelWithDebInfo

-- COMPILE_DEFINITIONS:_GNU_SOURCE;_FILE_OFFSET_BITS=64;HAVE_CONFIG_H

-- CMAKE_C_FLAGS:  -Wall -Wextra -Wformat-security -Wvla-Wwrite-strings -Wdeclaration-after-statement

-- CMAKE_CXX_FLAGS:  -Wall -Wextra -Wformat-security -Wvla-Woverloaded-virtual -Wno-unused-parameter

-- CMAKE_C_FLAGS_RELWITHDEBINFO: -O3 -g-fabi-version=2 -fno-omit-frame-pointer -fno-strict-aliasing -DDBUG_OFF

-- CMAKE_CXX_FLAGS_RELWITHDEBINFO: -O3 -g-fabi-version=2 -fno-omit-frame-pointer -fno-strict-aliasing -DDBUG_OFF

-- Configuring done

-- Generating done

-- Build files have been written to: /root/mysql-5.7.10

6,time make
这个时间比较长,需要耐心等待中,如下所示:

[root@linuxidc mysql-5.7.10]# timemake

……

Scanning dependencies of targetmysql_embedded

[100%] Building CXX objectlibmysqld/examples/CMakeFiles/mysql_embedded.dir/__/__/client/completion_hash.cc.o

[100%] Building CXX objectlibmysqld/examples/CMakeFiles/mysql_embedded.dir/__/__/client/mysql.cc.o

[100%] Building CXX objectlibmysqld/examples/CMakeFiles/mysql_embedded.dir/__/__/client/readline.cc.o

Linking CXX executable mysql_embedded

[100%] Built target mysql_embedded

Scanning dependencies of targetmysqltest_embedded

[100%] Building CXX objectlibmysqld/examples/CMakeFiles/mysqltest_embedded.dir/__/__/client/mysqltest.cc.o

Linking CXX executable mysqltest_embedded

[100%] Built target mysqltest_embedded

Scanning dependencies of targetmy_safe_process

[100%] Building CXX objectmysql-test/lib/My/SafeProcess/CMakeFiles/my_safe_process.dir/safe_process.cc.o

Linking CXX executable my_safe_process

[100%] Built target my_safe_process

7, time make install
这个执行起来比较快一些,如下所示:

[root@linuxidc mysql-5.7.10]# timemake install

……

-- Installing:/usr/local/mysql5710/mysql-test/lib/My/SafeProcess/my_safe_process

-- Up-to-date:/usr/local/mysql5710/mysql-test/lib/My/SafeProcess/my_safe_process

-- Installing: /usr/local/mysql5710/mysql-test/lib/My/SafeProcess/Base.pm

-- Installing:/usr/local/mysql5710/support-files/my-default.cnf

-- Installing:/usr/local/mysql5710/support-files/mysqld_multi.server

-- Installing:/usr/local/mysql5710/support-files/mysql-log-rotate

-- Installing:/usr/local/mysql5710/support-files/magic

-- Installing:/usr/local/mysql5710/share/aclocal/mysql.m4

-- Installing:/usr/local/mysql5710/support-files/mysql.server

8,配置my.cnf启动参数文件
[client]

#password      = [your_password]

port            = 3308

socket          = /usr/local/mysql5710/mysql.sock

loose-default-character-set=gbk

[mysqld]

default-storage-engine=INNODB

group_concat_max_len =99999

# generic configuration options

port            = 3307

socket          = /usr/local/mysql5710/mysql.sock

pid-file        = /usr/local/mysql5710/mysqld.pid

datadir        = /home/data/mysql5710/data

user            = mysql

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

skip-external-locking

skip-name-resolve

explicit_defaults_for_timestamp

……

9,初始化数据库
shell> bin/mysql_install_db--user=mysql    # Before MySQL 5.7.6

shell> bin/mysqld--initialize --user=mysql # MySQL 5.7.6 and up

shell> bin/mysql_ssl_rsa_setup              # MySQL 5.7.6 and up

9.1 利用my.cnf初始化
[root@linuxidc root]# cd /usr/local/mysql5710/bin/

[root@linuxidc bin]# ./mysqld--initialize --user=mysql --basedir=/usr/local/mysql5710--datadir=/home/data/mysql5710/data --defaults-file=/usr/local/mysql5710/my.cnf

2015-12-17T09:44:00.021750Z 0 [Warning] TIMESTAMPwith implicit DEFAULT value is deprecated. Please use--explicit_defaults_for_timestamp server option (see documentation for moredetails).

2015-12-17T09:44:00.462018Z 0 [Warning] InnoDB:New log files created, LSN=45790

2015-12-17T09:44:00.652738Z 0 [Warning] InnoDB:Creating foreign key constraint system tables.

2015-12-17T09:44:00.712997Z 0 [ERROR] unknownvariable 'defaults-file=/usr/local/mysql5710/my.cnf'

2015-12-17T09:44:00.713034Z 0 [ERROR] Aborting

[root@linuxidc bin]#

貌似报错了,不识别defaults-file的参数

9.2 默认启动
会报错如下:

[root@linuxidc bin]# rm -rf/home/data/mysql5710/data/*

[root@linuxidc bin]# ./mysqld--initialize --user=mysql --basedir=/usr/local/mysql5710--datadir=/home/data/mysql5710/data

2015-12-17T09:48:07.344700Z 0 [Warning]TIMESTAMP with implicit DEFAULT value is deprecated. Please use--explicit_defaults_for_timestamp server option (see documentation for moredetails).

2015-12-17T09:48:07.705225Z 0 [Warning]InnoDB: New log files created, LSN=45790

2015-12-17T09:48:07.795939Z 0 [Warning]InnoDB: Creating foreign key constraint system tables.

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/2c21c9027e0d4ba1deff1e5c3a99bd10.html