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

1,下载地址:

安装包下载地址:http://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.10.tar.gz

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

安装文档地址:http://dev.mysql.com/doc/refman/5.7/en/installing-source-distribution.html

文档干货在这里:

# 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/

 

 原博主csdn的blog地址:http://blog.csdn.net/mchdba/article/details/50354213,未经过允许,不得转载。

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

http://sourceforge.net/projects/boost/files/boost/1.59.0/boost_1_59_0.tar.gz

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来继续下载:

[[email protected]_idc_mon_1_12 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 http://www.sourceforge.net/projects/boost/files/boost/1.59.0/boost_1_59_0.tar.gz

然后继续编译:

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

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

[[email protected]_idc_mon_1_12 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

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

[[email protected]_idc_mon_1_12 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初始化

[[email protected]_idc_mon_1_12 root]# cd /usr/local/mysql5710/bin/

[[email protected]_idc_mon_1_12 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

[[email protected]_idc_mon_1_12 bin]#

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

9.2 默认启动

会报错如下:

[[email protected]_idc_mon_1_12 bin]# rm -rf/home/data/mysql5710/data/*

[[email protected]_idc_mon_1_12 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.

2015-12-17T09:48:07.807878Z 0 [Warning] Noexisting UUID has been found, so we assume that this is the first time thatthis server has been started. Generating a new UUID: 46bcea55-a4a3-11e5-b7ee-000c29ff8c77.

2015-12-17T09:48:07.809546Z 0 [Warning]Gtid table is not ready to be used. Table ‘mysql.gtid_executed‘ cannot beopened.

2015-12-17T09:48:07.811257Z 1 [Note] Atemporary password is generated for [email protected]: 4e3taITlXU%/

[[email protected]_idc_mon_1_12 bin]#

PS:看到这里有一个初始化root密码,记下来,不然启动完后,mysql登录就报密码错误登录不了。

10,安装ssl

[[email protected]_idc_mon_1_12 bin]#./mysql_ssl_rsa_setup

Generating a 2048 bit RSA private key

..........+++

.................................................................................+++

writing new private key to ‘ca-key.pem‘

-----

Generating a 2048 bit RSA private key

..+++

..................................................................................................................................................................+++

writing new private key to ‘server-key.pem‘

-----

Generating a 2048 bit RSA private key

.......................................................................+++

..+++

writing new private key to ‘client-key.pem‘

-----

[[email protected]_idc_mon_1_12 bin]#

11,部署启动服务

准备服务:

[[email protected]_idc_mon_1_12 bin]# cp../support-files/mysql.server /etc/init.d/mysqld5710

[[email protected]_idc_mon_1_12 bin]# chmod 700/etc/init.d/mysqld5710

[[email protected]_idc_mon_1_12 bin]# echo"export PATH=$PATH:/usr/local/mysql5710/bin">>/etc/profile

[[email protected]_idc_mon_1_12 bin]# source/etc/profile

[[email protected]_idc_mon_1_12 bin]#

设置开机启动

[[email protected]_idc_mon_1_12 bin]# chkconfigmysqld5710 on

[[email protected]_idc_mon_1_12 bin]#

启动报错:

[[email protected]_idc_mon_1_12 bin]# servicemysqld5710 start

Starting MySQL....The server quit withoutupdating PID file[失败]/local/mysql5710/mysqld.pid).

[[email protected]_idc_mon_1_12 bin]#

查看后台报错日志mysqld.log:

2015-12-17T09:54:40.004720Z 0 [ERROR]InnoDB: redo log file ‘./ib_logfile0‘ exists. Creating system tablespace withexisting redo log files is not recommended. Please delete all redo log file

s before creating new system tablespace.

2015-12-17T09:54:40.004744Z 0 [ERROR]InnoDB: InnoDB Database creation was aborted with error Generic error. You mayneed to delete the ibdata1 file before trying to start up again.

2015-12-17T09:54:40.305233Z 0 [ERROR]Plugin ‘InnoDB‘ init function returned error.

2015-12-17T09:54:40.305292Z 0 [ERROR]Plugin ‘InnoDB‘ registration as a STORAGE ENGINE failed.

2015-12-17T09:54:40.305305Z 0 [ERROR]Failed to initialize plugins.

2015-12-17T09:54:40.305315Z 0 [ERROR]Aborting

2015-12-17T09:54:40.305333Z 0 [Note] Binlogend

2015-12-17T09:54:40.306240Z 0 [Note]/usr/local/mysql5710/bin/mysqld: Shutdown complete

解决办法:

[[email protected]_idc_mon_1_12 data]# rm -rfib_logfile0 ib_logfile1

[[email protected]_idc_mon_1_12 data]#

然后再启动mysql,有报错信息如下:

2015-12-17T10:02:46.169594Z 0 [Warning] InnoDB: Cannot open tablemysql/plugin from the internal data dictionary of InnoDB though the .frm filefor the table exists. Please refer to http://de

v.mysql.com/doc/refman/5.7/en/innodb-troubleshooting.html for how toresolve the issue.

mysqld: Table ‘mysql.plugin‘ doesn‘t exist

2015-12-17T10:02:46.169680Z 0 [ERROR] Can‘t open the mysql.plugintable. Please run mysql_upgrade to create it.

2015-12-17T10:02:46.169907Z 0 [ERROR] unknown variable‘max_connection=10000‘

2015-12-17T10:02:46.169928Z 0 [ERROR] Aborting

修改my.cnf里面,注释掉max_connection=10000即可。后面陆陆续续报如下错误

2015-12-17T10:07:22.243181Z 0 [ERROR]unknown variable ‘max_user_connection=3009‘

2015-12-17T10:16:15.870396Z 0 [ERROR]unknown variable ‘thread_concurrency=8‘

2015-12-17T10:16:51.251271Z 0 [ERROR]unknown option ‘--myisam_recover‘

然后全部在my.cnf里面注释掉,再启动mysqld服务,正常启动了,如下所示:

[[email protected]_idc_mon_1_12 mysql5710]# servicemysqld5710 start

Starting MySQL..                                           [确定]

[[email protected]_idc_mon_1_12 mysql5710]#

至此,mysql5.7.10安装部署成功了。

12,重置密码

利用mysqladmin重置密码

[[email protected]_idc_mon_1_12 mysql5710]#./bin/mysqladmin -h localhost -uroot password "root" -p‘4e3taITlXU%/‘--socket=/usr/local/mysql5710/mysql.sock

mysqladmin: [Warning] Using a password onthe command line interface can be insecure.

Warning: Since password will be sent toserver in plain text, use ssl connection to ensure password safety.

[[email protected]_idc_mon_1_12 mysql5710]#

使用新密码登录:

[[email protected]_idc_mon_1_12 mysql5710]# mysql--socket=/usr/local/mysql5710/mysql.sock -uroot -proot

Warning: Using a password on the commandline interface can be insecure.

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 7

Server version: 5.7.10-log Sourcedistribution

Copyright (c) 2000, 2013, Oracle and/or itsaffiliates. All rights reserved.

Oracle is a registered trademark of OracleCorporation and/or its

affiliates. Other names may be trademarksof their respective

owners.

Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ toclear the current input statement.

mysql>

OK,mysql5.7.10安装彻底结束了,下面就可以开始验证5.7的新特性了。

13,番外篇

http://www.lengdo.com/blog/view/id/52.html,这里的blog主,说:MySQL启动后一切正常,但是大概在五六分钟后MySQL内存开始莫名飙升到500M,然后就稳定在500M左右,所有的 buffer, size, cache 等都是按最小配置,无 SQL 请求,甚至关闭 innodb 都无效。

所以准备探讨一番他的症状所在。

启动mysql5.7后,剩余1927M内存,如下所示:

[[email protected]_idc_mon_1_12 mysql-5.7.10]#

[[email protected]_idc_mon_1_12 mysql-5.7.10]# free-m

total       used       free    shared    buffers     cached

Mem:        32110      30182       1927          0        349     24095

-/+ buffers/cache:       5737     26372

Swap:         3967         12       3955

[[email protected]_idc_mon_1_12 mysql-5.7.10]#

[[email protected]_idc_mon_1_12 mysql-5.7.10]#

停止mysql5.7后,剩余2841m内存,如下所示:

[[email protected]_idc_mon_1_12 mysql-5.7.10]#service mysqld5710 stop

Shutting down MySQL..                                      [确定]

[r[email protected]_idc_mon_1_12 mysql-5.7.10]# free-m

total       used       free    shared    buffers     cached

Mem:        32110      29268       2841          0        349     24083

-/+ buffers/cache:       4835     27274

Swap:         3967         12       3955

[[email protected]_idc_mon_1_12 mysql-5.7.10]#

大概用了一个G左右,而我的buffer_pool设置就是4G,可能是启动mysql加载buffer pool的内存消耗,有待后续验证。

时间: 2024-12-14 21:49:24

MySQL 5.7.10最新版本源代码安装详细过程的相关文章

MySQL 5.7.18 zip版本的安装使用方法

MySQL 5.7.18 zip版本的安装使用方法 这个版本的MySQL不像那种点击就可以立即安装,一直下一步就OK的,这个需要自己进行配置,虽然有点小麻烦,我还是比较喜欢使用这个版本,因为比较单一,不会因为安装数据库,还要安装其他插件工具. 1.下载路径 官网MySQL zip文件下载地址:https://dev.mysql.com/downloads/mysql/ 点击 download 按钮,根据提示进行下载,不用登录账号:(下载文件到,如:D:\\) 2.将下载到D:\\下的 mysql

Linux下WebSphereV8.5.5.0 安装详细过程

Linux下WebSphereV8.5.5.0 安装详细过程 自WAS8以后安装包不再区别OS,一份介质可以安装到多个平台.只针对Installation Manager 进行了操作系统的区分 ,Websphere产品介质必须通过专门的工具Install Managere安装.进入IBM的官网http://www.ibm.com/us/en/进行下载.在云盘http://yun.baidu.com/share/linkshareid=2515770728&uk=4252782771 中是Linu

VMware Tools (ubuntu系统)安装详细过程与使用

前一段时间博主在VMware虚拟机上安装了Ubuntu系统,如果还没有安装的同学可以参考博主上一篇文章:VMware Ubuntu安装详细过程. 猿友们都知道linux不太好用,如果你想将你主机Windows上的文件或安装包放到虚拟机上,VMware Tools是必不可少的工具. 欢迎关注,相互学习讨论,后续还会有更多linux搭建java开发环境和框架相关博客. 下面小宝鸽附上VMware Tools安装的详细流程. 1.打开虚拟机VMware Workstation,启动Ubuntu系统,菜

Mysql 5.7.10以上版本安装大坑

mysql解压缩版的配置已经方便无比了,但是也正是由于官方的不断优化,导致传统的套路一次次被修改.也让像我这样的萌新撞了个大墙. [注:本篇博客适用mysql5.7.10~5.7.15,如果版本已太过久远,请慎重.] 先说问题:mysql安装配置完成并成功启动服务后,原以为可以直接执行 mysql 或者 mysql -uroot -p 的方法进行超级管理员的登录.然而当前版本的的mysql已经不支持无密码的登录了.所以会报错 ERROR 1045 (28000): Access denied f

MYSQL—第二部分(Linux版本的安装和数据表的操作)

Linux版本的安装(过于简单了) 安装: ? 1 yum install mysql-server 服务端启动 ? 1 mysql.server start 客户端连接 ? 1 2 3 4 5 6 7 连接:     mysql -h host -u user -p     常见错误:         ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2), it

在VMware上安装MAC OS10.15最新版本并安装Xcode11.4教程(所有坑已经走过)

最新我们新开了iOS开发这门课程但是电脑是Windows系统,所以只能在虚拟机上安装一个苹果系统的电脑来支持xcode11编写代码程序. 下面就是具体安装步骤和一些下载资源. 首先我们要知道最新版本的Xcode 11支持的是15.5以上的虚拟机以及10.15以上的苹果系统,如果这两样你没有拥有那就无法拥Xcode11. 虚拟机15.5以上的版本可以自行在官网安装这里就不多做解释了. 安装虚拟机以后如果想拥有一个苹果系统的电脑,我们需要用unlocker黑苹果工具,才能让虚拟机在新建虚拟机的时候有

Mysql安装详细过程,tar方式

1.创建mysql用户和mysql用户组 groupadd mysql useradd -r -g mysql mysql 2. 到我的共享网盘下载mysql-5.7.17程序包 链接:http://pan.baidu.com/s/1gfAA87p 密码:iuti 3.拷贝下载的安装包到linux系统中,可以通过sftp或是共享网盘 tar -zxvf mysql-5.7.17-linux-glibc2.5-x86_64 cp mysql-5.7.17-linux-glibc2.5-x86_64

hyper-v Centos安装后网络配置及Nginx安装详细过程(转)

  在Hyper-V环境下进行安装Centos7系统 今天需要在linux系统中配置Nginx环境,网上找了些资料.在安装过程中碰到了很多问题,花了一天的时间终于配置好了.相对于在window环境下配置Ngix还是比较简单的.花了点时间记录下来,方便以后查询: 新安装的Centos系统默认情况下是不能上网的,需要经过相应的配置:选择对应的虚拟机,点击“虚拟交换机管理器”: 创建外部交换机: 选择对应的虚拟机打开设置界面: 添加一个“旧版网络适配器”: 关联网络适配器与交换机: 经过以上设置hyp

apache2.2.31源码安装详细过程

本文是把apache安装在虚拟机中的详细过程,有需要的朋友可以参考下: 首先我们大体先分个步骤: 安装编译环境 卸载原有apache 下载源码包 安装apache 修改配置文件 测试apache 查看apache生成目录 把apache加入系统服务以及开机自启动 一.安装编译环境 在安装apache之前,我们需要安装编译apache时所需要的相关软件包: yum -y install gcc gcc++ zlib zlib-devel 二.卸载原有Apache rpm -qa |grep htt