MySQL5.7.20编译安装

尝试一下 想着   我在arm上面最终安装失败了。 

https://www.cnblogs.com/shengdimaya/p/8027507.html
1:官网下载source code源码安装文件
1
https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-boost-5.7.20.tar.gz

  

2:安装准备

先看一下文件和路径:

1
2
3
4
[root@16-31 mysql]# pwd
/home/mysql
[root@16-31 mysql]# ls
mysql-boost-5.7.20.tar.gz

  

我们看一下官网给出的源码安装需要的条件:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
CMake, which is used as the build framework on all platforms. CMake can be downloaded from http://www.cmake.org.
 
A good make program. Although some platforms come with their own make implementations, it is highly recommended that you use GNU make 3.75 or higher. It may already be available on your system as gmake. GNU make is available from http://www.gnu.org/software/make/.
 
A working ANSI C++ compiler. See the description of the FORCE_UNSUPPORTED_COMPILER. option for some guidelines.
 
The Boost C++ libraries are required to build MySQL (but not to use it). Boost 1.59.0 must be installed. To obtain Boost and its installation instructions, visit the official site. After Boost is installed, tell the build system where the Boost files are located by defining the WITH_BOOST option when you invoke CMake. For example:
 
shell> cmake . -DWITH_BOOST=/usr/local/boost_1_59_0
Adjust the path as necessary to match your installation.
 
The ncurses library.
 
Sufficient free memory. If you encounter problems such as “internal compiler error” when compiling large source files, it may be that you have too little memory. If compiling on a virtual machine, try increasing the memory allocation.
 
Perl is needed if you intend to run test scripts. Most Unix-like systems include Perl. On Windows, you can use a version such as ActiveState Perl.

  

上面是官网给的例子,我们先需要下载一个Boost C++ 1.59.0(这是一组扩充C++功能的经过同行评审(Peer-reviewed)且开放源代码程序库。大多数的函数为了能够以开放源代码、封闭项目的方式运作,而授权于Boost软件许可协议(Boost Software License)之下。),下载地址:

1
https://sourceforge.net/projects/boost/files/boost/1.59.0/boost_1_59_0.tar.gz/download

  

接下来我们开始进行一些准备工作(安装依赖包,用户以及目录):

1
2
3
4
5
6
yum -y install gcc gcc-c++ ncurses ncurses-devel bison libgcrypt perl make cmake
groupadd mysql
useradd -r -g mysql -s /bin/false -M mysql
mkdir -p /home/mysql/{data,log,tmp}
ls /home/mysql/
chown -R mysql:mysql /home/mysql/

  

3:安装

解压两个压缩文件,MySQL和Boost,然后开始进行编译安装:

1
[root@16-31 mysql-5.7.20]# cmake . -DCMAKE_INSTALL_PREFIX=/home/mysql -DMYSQL_DATADIR=/home/mysql/data -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DMYSQL_TCP_PORT=3306 -DMYSQL_USER=mysql -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DENABLE_DOWNLOADS=1 -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/usr/local/boost

  

然后进行make

1
make

  

这个过程时间会比较久,我这边大概两个小时的样子,然后安装:

1
make install

  

然后我们先把安装目录添加到环境变量中:

1
2
[root@mdw mysql]# echo "export PATH=$PATH:/home/mysql/bin">>/etc/profile
[root@mdw mysql]# source /etc/profile

  

以上步骤完成以后就是初始化数据库了:

1
[root@mdw datafile]# mysqld --defaults-file=/etc/my.cnf  --initialize --user='mysql' --log_error_verbosity --explicit_defaults_for_timestamp

  

OK,现在我们初始化也完成了,接下来我们配置一下我们的my.cnf文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
[client]
port            = 3306
socket          = /home/datafile/mysql3306/temp/mysql.sock
[mysqld]
# Skip #
skip_name_resolve              = 1 
skip-external-locking          = 1
symbolic-links= 0                   
 
 
# GENERAL #
user = mysql
default_storage_engine = InnoDB
character-set-server = utf8
socket  = /home/datafile/mysql3306/temp/mysql.sock
pid_file =/home/datafile/mysql3306/temp/mysqld.pid
basedir = /home/mysql
port = 3306
bind-address = 0.0.0.0
log-warnings = 2 
explicit_defaults_for_timestamp = off
#sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
#read_only=on
sql_mode=NO_ENGINE_SUBSTITUTION 
# MyISAM #
key_buffer_size                = 32M    #size of the buffer used for index blocks#
#myisam_recover                 = FORCE,BACKUP
 
# SAFETY #
max_allowed_packet             = 16M
max_connect_errors             = 1000000
sysdate_is_now                 = 1
#innodb = FORCE
#innodb_strict_mode = 1
 
# Replice #
 server-id = 313306
 relay_log = mysqld-relay-bin
 gtid_mode = on
 enforce-gtid-consistency
 log-slave-updates = on
 master_info_repository =TABLE
 relay_log_info_repository =TABLE
# rpl_semi_sync_master_enabled=1
# rpl_semi_sync_master_timeout=200     # 0.2 second
 
# DATA STORAGE #
 datadir = /home/datafile/mysql3306/data/
 tmpdir = /home/datafile/mysql3306/temp/
  
BINARY LOGGING #
 log_bin =/home/datafile/mysql3306/log/mysql-bin
 max_binlog_size = 1000M
 binlog_format = row
 expire_logs_days = 7
# sync_binlog = 1
 
 # CACHES AND LIMITS #
 tmp_table_size                 = 32M
 max_heap_table_size            = 32M
 query_cache_type               = 0
 query_cache_size               = 0
 max_connections                = 4000
 thread_cache_size              = 2048
 open_files_limit               = 65535
 table_definition_cache         = 4096
 table_open_cache               = 4096
 sort_buffer_size               = 20M
 read_buffer_size               = 2M
 read_rnd_buffer_size           = 2M
 #thread_concurrency             = 24
 join_buffer_size = 1M
# table_cache = 32768
 thread_stack = 512k
 max_length_for_sort_data = 16k
 
 
 # INNODB #
 innodb_flush_method            = O_DIRECT
 innodb_log_buffer_size = 16M
 innodb_flush_log_at_trx_commit = 2
 innodb_file_per_table          = 1
 innodb_buffer_pool_size        = 2G
 innodb_buffer_pool_instances = 8
 innodb_stats_on_metadata = off
 innodb_open_files = 8192
 innodb_read_io_threads = 8
 innodb_write_io_threads = 16
 innodb_io_capacity = 20000
 innodb_thread_concurrency = 0
 innodb_lock_wait_timeout = 60
 innodb_old_blocks_time=1000
 innodb_use_native_aio = 1
 innodb_purge_threads=1 
 innodb_change_buffering=all
 innodb_log_file_size = 128M
 innodb_log_files_in_group = 3
 innodb_data_file_path  = ibdata1:1024M:autoextend
  
 # LOGGING #
 log_error                      = /home/datafile/mysql3306/log/mysql-error.log
 # log_queries_not_using_indexes  = 1
 # slow_query_log                 = 1
 slow_query_log_file            = /home/datafile/mysql3306/log/slowlog_36215.log
 
 # TimeOut #
 interactive_timeout = 30
 wait_timeout        = 30
 
 
[mysqldump]
quick  
max_allowed_packet = 16M
 
[mysql]
no-auto-rehash 
 
 
[myisamchk]
key_buffer_size = 256M
sort_buffer_size = 256M
read_buffer = 2M
write_buffer = 2M
 
[mysqlhotcopy]
interactive-timeout

  

这里要说明下,就是参数要根据自己的机器配置,不能直接照抄使用,然后直接启动mysql:

1
mysqld_safe --defaults-file=/etc/my.cnf &

  

我们从日志中找到初始密码:

2017-12-11T06:59:05.094646Z 1 [Note] A temporary password is generated for root@localhost: ,fsQ:tkik6un

登录修改密码就好了。 最后,我们将我们的编译包打包,以后可以直接拷贝使用。

4:解压使用编译压缩包

先拷贝:

scp   /home/mysql.tar  sa@172.16.16.34:/home/sa/

解压:

[root@sdw1 home]# mv mysql.tar /home/
[root@sdw1 home]# tar zxvf mysql.tar

然后我们创建MySQL相关的用户和目录以及授权等:

1
2
3
4
5
6
7
groupadd mysql
useradd -r -g mysql -s /bin/false -M mysql
mkdir -p /home/datafile/mysql3306/{data,log,temp}
ls /home/datafile/mysql3306
chown -R mysql:mysql /home/datafile/mysql3306
echo "export PATH=$PATH:/home/mysql/bin">>/etc/profile
source /etc/profile

  

然后使用刚才配置文件再初始化一下(要修改个别参数):

[root@sdw1 mysql3306]# mysqld --defaults-file=/etc/my.cnf  --initialize --user='mysql' --log_error_verbosity --explicit_defaults_for_timestamp
[root@sdw1 mysql3306]# mysqld_safe --defaults-file=/etc/my.cnf &

然后找到密码初始化搞定。

热衷于学习讨论MySQL和SQL Server,NoSQL等数据库技术,欢迎加入SQL优化群:659336691

[转帖]MySQL5.7.20编译安装的更多相关文章

  1. MySQL5.7.20编译安装

    1:官网下载source code源码安装文件 https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-boost-5.7.20.tar.gz 2:安装准备 ...

  2. mysql5.7.11编译安装以及修改root密码小结

    系统是cenos6.7 64位的,默认mysql5.7.11下载到/usr/local/src,安装目录在/app/local/mysql目录下,mysql数据放置目录/app/local/data. ...

  3. mysql-5.6.17编译安装和常见问题

    mysql-5.6.17编译安装和常见问题 以前用的是MySQL的5.1版本,且使用的是免编译的包,安装简单.最近换了5.6版本的MySQL,安装过程出现了不少问题. 1. 卸载原来版本的MySQL ...

  4. 安装MYSql Windows7下MySQL5.5.20免安装版的配置

    MySQL Windows安装包说明: 1.mysql-5.5.20-win32.msi:Windows 安装包,图形化的下一步下一步的安装. 2.mysql-5.5.20.zip,这个是window ...

  5. Mapnik 3.0.20编译安装

    1. 确定epel安装 yum install -y epel-release 2. 按照<CentOS7.2部署node-mapnik>一文中的步骤,手动安装 gcc-6.2.0 和 b ...

  6. CentOS6.5内 MySQL5.7.19编译安装

    作为博主这样的Linux菜鸟,CentOS下最喜欢的就是yum安装.但有时候因为特殊情况(例如被墙等),某些软件可能没办法直接通过yum来安装,这时候我们可以使用编译安装或者直接二进制文件安装. 本博 ...

  7. MySQL5.7 的编译安装

    转: 5.7的安装: https://www.insp.top/article/make-install-mysql-5-7 5.6的安装: https://www.chenyudong.com/ar ...

  8. mysql5.7.x 编译安装

    一.卸载mariadb [root@mysql5 ~]# rpm -qa mariadb* mariadb-libs--.el7.centos.x86_64 [root@template tools] ...

  9. mysql5.1的编译安装 ----针对第一次安装mysql的

    由于是第一次安装,不能确定你是否有安装编译和mysql所要依赖的插件,使用我是当做你最原始的安装环境.  1.安装mysql5.1的依赖包 yum install -y gcc gcc-c++ aut ...

随机推荐

  1. 移动端布局Rem

    一.最好用没有之一 http://www.jianshu.com/p/b00cd3506782 虽然博主说这个方案已经过期了 但是新方案还没有理解 就接着沿用这个 可以根据自己常用的设计稿的宽度修改 ...

  2. MessagePack Java Jackson 序列化和反序列化 POJO 为 MessagePack 的数组类型用来与 msgpack-java:0.6 保持兼容性

    在 msgpack-java 0.6 或者早期的版本中,POJO 在 MessagePack 中被序列化和反序列化为数组变量. 变量的顺序是基于 Java 类中变量的内部顺序了,这种本来是一种原生的序 ...

  3. ACM之一个简单的数学问题

    一个简单的数学题 时间限制:3000 ms  |  内存限制:65535 KB 难度:3 描述 zyc最近迷上了数学,一天,dj想出了一道数学题来难住他.算出1/n,但zyc一时答不上来希望大家能编程 ...

  4. 重启php7.0-fpm

    /etc/init.d/php7.0-fpm restart

  5. $\LaTeX$数学公式大全2

    $2\ Math\ Constructs$$\frac{abc}{xyz}$ \frac{abc}{xyz}$f'$ f'$\sqrt{abc}$ \sqrt{abc}$\sqrt[n]{abc}$ ...

  6. python配置文件

    python有两种配置文件,file.ini和file.json 一.ini文件如下: db_config.ini [baseconf] host=127.0.0.1 port=3306 user=r ...

  7. H264编码原理以及I帧、B和P帧详解, H264码流结构分析

    H264码流结构分析 http://blog.csdn.net/chenchong_219/article/details/37990541 1.码流总体结构: h264的功能分为两层,视频编码层(V ...

  8. Nginx服务应用

    虚拟主机 基于域名的虚拟主机 所谓基于域名的虚拟主机,意思就是通过不同的域名区分不同的虚拟主机,基于域名的虚拟主机是企业应用最广的虚拟主机类型,几乎所有对外提供服务的网站都是使用基于域名的虚拟主机 基 ...

  9. 在oracle中使用基表建立月表的存储过程

    某些系统需要按月分表来保存数据.下面的存储过程演示了如何使用基表来建立每个月的月表. 处理思路是:     1:首先,为基表建立好表和对应的索引.     2:将基表保存到一个存储过程需要的表中.   ...

  10. 多线程分配线程的实现方案:CountDownLatch类

    需求:假如我们本地有4个文件需要解析,每个文件的内容为20万行.为了提高效率我们要创建4个线程进行处理.等4个线程处理完,要在文件日志表中记录处理状态. 一般的的解决方法是使用join,join用于让 ...