MySQL数据库系列2---从源码编译MySQL-5.7.19

在网上百度到了这么一篇文章

http://download.csdn.net/download/machen_smiling/9755003
http://blog.csdn.net/u012453679/article/details/60480682
http://blog.csdn.net/xyang81/article/details/51792144

http://blog.csdn.net/xiexingshishu/article/details/72860356
https://dev.mysql.com/downloads/mysql/
http://www.bubuko.com/infodetail-2259763.html
http://www.cnblogs.com/AllenJol/p/6609929.html
http://heyiyi.blog.51cto.com/205455/1707904/
https://github.com/mysql/mysql-server/releases

所以,本节就按照这篇文章来操作一遍!

http://blog.csdn.net/sungsasong/article/details/76278361

注意:

注意:mysql 5.7.17 安装略不用于 mysql 5.6
第一:需要指定 boost
第二:初始化也不同了
最后记: 
在企业的生产环境中,追求的是稳定性,官方的二进制版本是经过了充分的验证的,
虽然使用源码安装会带来性能方面的提升,但是编码复杂,
如果不清楚编译的参数,依然推荐大家使用二进制的方式进行安装。

===========================实际操作==========================

1、老套路,将源码包上传之Linux服务器

https://dev.mysql.com/downloads/mysql/

可以看到下面的图

启动下载,本质上是下面的网址

https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-boost-5.7.19.tar.gz
wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-boost-5.7.19.tar.gz
tar -zvxf mysql-boost-5.7.19.tar.gz
~/mysql_5.7.19_debug# ls
mysql-5.7.19  mysql-boost-5.7.19.tar.gz

 

2、安装编译环境所需要的包和一些依赖包

注意,不同操作系统的命令略有不同,我的是ubuntu

apt-get install -y cmake 
apt-get install -y make 
apt-get install -y  gcc 
apt-get install -y g++
apt-get install libncurses5-dev

 

3、创建必要的目录,并授权 

root@myhost:~/mysql_5.7.19_debug# mkdir mysql
root@myhost:~/mysql_5.7.19_debug# mkdir data
root@myhost:~/mysql_5.7.19_debug# mkdir conf
root@myhost:~/mysql_5.7.19_debug# mkdir sbin
root@myhost:~/mysql_5.7.19_debug# mkdir boost
root@myhost:~/mysql_5.7.19_debug# ls
data  mysql  mysql-5.7.19  mysql-boost-5.7.19.tar.gz

root@myhost:~/mysql_5.7.19_debug# chown -R mysql.mysql ./data ./mysql ./conf ./sbin ./boost

root@myhost:~/mysql_5.7.19_debug# ls -al
total 47696
drwxr-xr-x  8 root  root      4096 Aug 29 23:18 .
drwx------ 65 root  root      4096 Aug 29 22:32 ..
drwxr-xr-x  2 mysql mysql     4096 Aug 29 23:18 boost
drwxr-xr-x  2 mysql mysql     4096 Aug 29 23:01 conf
drwxr-xr-x  2 mysql mysql     4096 Aug 29 22:49 data
drwxr-xr-x  2 mysql mysql     4096 Aug 29 22:49 mysql
drwxr-xr-x 37  7161 31415     4096 Aug 29 23:18 mysql-5.7.19
-rw-r--r--  1 root  root  48799895 Aug 29 22:36 mysql-boost-5.7.19.tar.gz
drwxr-xr-x  2 mysql mysql     4096 Aug 29 23:08 sbin

 

4、执行编译命令

参考了https://zhidao.baidu.com/question/136500683.html

cmake -DCMAKE_INSTALL_PREFIX=/root/mysql_5.7.19_debug/mysql -DMYSQL_DATADIR=/root/mysql_5.7.19_debug/data -DMYSQL_UNIX_ADDR=/root/mysql_5.7.19_debug/data/mysqld.sock -DWITH_INNOBASE_STORAGE_ENGINE=1 -DSYSCONFDIR=/root/mysql_5.7.19_debug/conf -DINSTALL_SBINDIR=/root/mysql_5.7.19_debug/sbin -DENABLED_LOCAL_INFILE=1 -DMYSQL_TCP_PORT=3306 -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DMYSQL_USER=mysql -DWITH_DEBUG=1 -DENABLE_PROFILING=1 -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/root/mysql_5.7.19_debug/boost

出现了这样的字样表示成功

-- If you are inside a firewall, you may need to use an https proxy: export https_proxy=http://example.com:80
-- Performing Test HAVE_MISLEADING_INDENTATION
-- Performing Test HAVE_MISLEADING_INDENTATION - Failed
-- Library mysqlserver depends on OSLIBS -lpthread;m;rt;crypt;dl;aio
-- INSTALL mysqlclient.pc lib/pkgconfig
-- CMAKE_BUILD_TYPE: Debug
-- COMPILE_DEFINITIONS: _GNU_SOURCE;_FILE_OFFSET_BITS=64;HAVE_CONFIG_H;HAVE_LIBEVENT1
-- CMAKE_C_FLAGS:  -fPIC -Wall -Wextra -Wformat-security -Wvla -Wwrite-strings -Wdeclaration-after-statement -Werror
-- CMAKE_CXX_FLAGS:  -fPIC -Wall -Wextra -Wformat-security -Wvla -Woverloaded-virtual -Wno-unused-parameter -Werror
-- CMAKE_C_LINK_FLAGS: 
-- CMAKE_CXX_LINK_FLAGS: 
-- CMAKE_C_FLAGS_DEBUG: -g -fabi-version=2 -fno-omit-frame-pointer -fno-strict-aliasing -DENABLED_DEBUG_SYNC -DSAFE_MUTEX
-- CMAKE_CXX_FLAGS_DEBUG: -g -fabi-version=2 -fno-omit-frame-pointer -fno-strict-aliasing -DENABLED_DEBUG_SYNC -DSAFE_MUTEX
-- Configuring done
-- Generating done
-- Build files have been written to: /root/mysql_5.7.19_debug/mysql-5.7.19

 

5、编译安装 

make && make install

当你看到这样的结果,表示成功了!

-- Installing: /root/mysql_5.7.19_debug/mysql/mysql-test/./include/remove_debug_point.inc
-- Installing: /root/mysql_5.7.19_debug/mysql/mysql-test/./include/innodb-util.inc
-- Installing: /root/mysql_5.7.19_debug/mysql/mysql-test/./include/test_outfile.inc
-- Installing: /root/mysql_5.7.19_debug/mysql/mysql-test/./include/gis_generic.inc
-- Installing: /root/mysql_5.7.19_debug/mysql/mysql-test/./include/show_master_status.inc
-- Installing: /root/mysql_5.7.19_debug/mysql/mysql-test/./include/have_slave_parallel_type_logical_clock.inc
-- Installing: /root/mysql_5.7.19_debug/mysql/mysql-test/./include/have_cp866.inc
-- Installing: /root/mysql_5.7.19_debug/mysql/mysql-test/./include/stop_slave_io.inc
-- Installing: /root/mysql_5.7.19_debug/mysql/mysql-test/./include/subquery_sj.inc
-- Installing: /root/mysql_5.7.19_debug/mysql/mysql-test/./include/have_ucs2.inc
-- Installing: /root/mysql_5.7.19_debug/mysql/mysql-test/./mtr
-- Up-to-date: /root/mysql_5.7.19_debug/mysql/mysql-test/mtr
-- Up-to-date: /root/mysql_5.7.19_debug/mysql/mysql-test/mysql-test-run
-- Installing: /root/mysql_5.7.19_debug/mysql/mysql-test/lib/My/SafeProcess/my_safe_process
-- Up-to-date: /root/mysql_5.7.19_debug/mysql/mysql-test/lib/My/SafeProcess/my_safe_process
-- Installing: /root/mysql_5.7.19_debug/mysql/mysql-test/lib/My/SafeProcess/Base.pm
-- Installing: /root/mysql_5.7.19_debug/mysql/support-files/mysqld_multi.server
-- Installing: /root/mysql_5.7.19_debug/mysql/support-files/mysql-log-rotate
-- Installing: /root/mysql_5.7.19_debug/mysql/support-files/magic
-- Installing: /root/mysql_5.7.19_debug/mysql/share/aclocal/mysql.m4
-- Installing: /root/mysql_5.7.19_debug/mysql/support-files/mysql.server

添加配置文件,注意:这个配置文件可以没有

cd /root/mysql_5.7.19_debug/conf/
root@myhost:~/mysql_5.7.19_debug/conf# ls
root@myhost:~/mysql_5.7.19_debug/conf# touch my.cnf
root@myhost:~/mysql_5.7.19_debug/conf# 

6)尝试debug

cd sbin
root@myhost:~/mysql_5.7.19_debug/sbin# ls -al
total 162384
drwxr-xr-x 2 mysql mysql      4096 Aug 29 23:46 .
drwxr-xr-x 8 root  root       4096 Aug 29 23:18 ..
-rwxr-xr-x 1 root  root  166265473 Aug 29 23:40 mysqld
~/mysql_5.7.19_debug/sbin# gdb mysqld
GNU gdb (Ubuntu 7.7.1-0ubuntu5~14.04.2) 7.7.1
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from mysqld...done.
(gdb) break main
Breakpoint 1 at 0xe91c5c: file /root/mysql_5.7.19_debug/mysql-5.7.19/sql/main.cc, line 25.
(gdb) run
Starting program: /root/mysql_5.7.19_debug/sbin/mysqld 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

Breakpoint 1, main (argc=1, argv=0x7fffffffe2d8)
    at /root/mysql_5.7.19_debug/mysql-5.7.19/sql/main.cc:25
25	  return mysqld_main(argc, argv);
(gdb) 

迈出了第1步骤!

转载于:https://my.oschina.net/qiangzigege/blog/1525642

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值