CentOS 7 编译安装 MySQL-5.7.9

本文详细介绍了如何在CentOS 7环境下手动编译安装MySQL-5.7.9,包括配置防火墙、创建用户和用户组、下载编译依赖、编译安装MySQL、配置my.cnf、设置环境变量、创建数据库目录、初始化数据库、设置开机启动以及创建数据库用户等步骤。
摘要由CSDN通过智能技术生成

CentOS 7 编译安装 MySQL-5.7.9

本文主要来自https://typecodes.com/web/centos7compilemysql.html

实验环境

  1. VMware 12中最小化安装的CentOS 7 x64
  2. CentOS 7 配置为 2cpu 2G内存(原来分配1G,但是在编译MySQL到54%时卡住)
  3. 下载MySQL-5.7.9版本

配置防火墙和开放端口

以下操作在root用户中操作

[root@localhost ~]#systemctl stop firewalld.service #关闭防火墙
[root@localhost ~]#systemctl disable firewalld.service #禁止防火墙开机启动
[root@localhost ~]#vi /etc/selinux/config #关闭selinux
修改为SELINUX=disabled
[root@localhost ~]#setenforce 0 #使配置生效


[root@localhost ~]#yum install -y iptables-services #安装防火墙规则
[root@localhost ~]#vi /etc/sysconfig/iptables #配置防火墙规则

-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT #添加
-A INPUT -p tcp -m state --state NEW -m tcp --dport 3306 -j ACCEPT #添加
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited

esc键,然后输入命令 :wq! 保存修改
[root@localhost ~]#systemctl restart iptables.service #重启防火墙使配置生效
[root@localhost ~]#systemctl enable iptables.service #设置防火墙开机启动

创建mysql用户和用户组

首先创建一个名为mysql且没有登录权限的用户和一个名为mysql的用户组

[root@localhost mysql]# groupadd -r mysql && useradd -r -g mysql -s /bin/false -M mysql

下载编译MySQL5.7.9时需要的工具

######CMake编译工具
[root@localhost ~]# wget -c http://git.typecodes.com/libs/ccpp/cmake-3.2.1.tar.gz
[root@localhost ~]# tar -zxf cmake-3.2.1.tar.gz && cd cmake-3.2.1
[root@localhost cmake-3.2.1]# ./configure
[root@localhost cmake-3.2.1]# make && make install [默认安装路径是/usr/local/bin]
[root@localhost cmake-3.2.1]# cmake –version [查看cmake版本]
cmake version 3.2.1

CMake suite maintained and supported by Kitware (kitware.com/cmake).
[root@localhost cmake-3.2.1]# cd ~ && rm -rf cmake-3.2.1*

######Ncurses:提供功能键定义(快捷键),屏幕绘制以及基于文本终端的图形互动功能的动态库。
[root@localhost ~]# yum -y install ncurses-devel

#######bison:GNU分析器生成器
[root@localhost ~]# wget -c http://git.typecodes.com/libs/ccpp/bison-3.0.tar.gz
[root@localhost ~]# tar -zxf bison-3.0.tar.gz && cd bison-3.0/ && ./configure
[root@localhost bison-3.0]# make && make install
[root@localhost bison-3.0]# cd ~ && rm -rf bison-3.0*

#######Boost库:一个开源可移植的C++库,是C++标准化进程的开发引擎之一
下载 boost_1_59_0并上传到/root/目录(一定要这个版本以上,尝试多次安装1.57.0版本导致后面安装mysql5.7.9的时候会报找不到这个库的错误)
[root@typecodes ~]# tar -zxf boost_1_59_0.tar.gz && cd boost_1_59_0/
[root@localhost boost_1_59_0]# ./bootstrap.sh
[root@localhost boost_1_59_0]# ./b2 stage threading=multi link=shared
[root@localhost boost_1_59_0]# ./b2 install threading=multi link=shar

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值