mysql5.7 for centos7.6源码安装

1.安装前的准备
1) 关闭防火墙修改SELinux
vim /etc/selinux/config
SELINUX=disabled

2)关闭防火墙
systemctl status firewalld.service
systemctl stop firewalld.service
systemctl disable firewalld.service

3)检查操作系统上是否安装了MySQL
rpm -qa |grep mariadb
yum remove mysql-libs
rpm -qpi xxxx.rpm

4)安装MySQL所需要的工具
yum install \
vim \
git \
gcc \
gcc-c++ \
wget \
make \
cmake \
automake \
autoconf \
libaio \
libtool \
net-tools \
bison \
bison-devel \
libaio-devel \
ncurses-devel \
perl-Data-Dumper \
-y

yum -y install openssl openssl-devel

2.添加用户和组:
groupadd apps
useradd -d /home/apps -g apps -m apps
passwd apps

3.创建目录及授权
mkdir -p /apps/dbdat/mysql57_3306
mkdir -p /apps/binlog/mysql57_3306
mkdir -p /apps/conf/mysql
mkdir -p /apps/logs/mysql
mkdir -p /apps/svr/mysql57
mkdir -p /apps/tmp
mkdir -p /apps/run
mkdir -p /apps/sh/tool
mkdir -p /apps/rpm

chown -R apps:apps /apps
chmod -R 755 /apps

4.配MySQL环境变量
vi /etc/profile
export LANG=en_US.UTF-8
export PATH=$PATH:/usr/sbin
export PATH=$PATH:/apps/svr/mysql57/bin
export PATH=$PATH:/apps/sh/tool/
export MYSQL_HISTFILE=/dev/null

~/.mysql_history

source /etc/profile

5.下载/解压
cd /apps/rpm
wget http://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.28.tar.gz
wget http://downloads.sourceforge.net/project/boost/boost/1.59.0/boost_1_59_0.tar.gz

cd /apps/rpm
tar -xzvf boost_1_59_0.tar.gz
tar -xzvf mysql-5.7.28.tar.gz

6.进入解压完的mysql-5.7.27目录,编译源码并生成makefile。

cd mysql-5.7.31

编译并安装

cmake \
-DCMAKE_INSTALL_PREFIX=/apps/svr/mysql57 \
-DMYSQL_DATADIR=/apps/dbdat/mysql57_3306 \
-DSYSCONFDIR=/apps/conf/mysql \
-DWITH_BOOST=/apps/rpm/mysql-5.7.31/boost \
-DDEFAULT_CHARSET=utf8mb4 \
-DDEFAULT_COLLATION=utf8mb4_unicode_ci \
-DEXTRA_CHARSETS=all \
-DENABLED_LOCAL_INFILE=1 \
-DMYSQL_UNIX_ADDR=/tmp/mysql3306.sock \
-DMYSQL_TCP_PORT=3306

-DWITH_SYSTEMD=1 \ 去掉这个,加上不会安装mysqld_safe

  1. 编译

make -j 4
make -j grep processor /proc/cpuinfo | wc -l && make install

8.安装
make install

9.配置mysql参数
vim /apps/conf/mysql/mysql57_3306.cnf

cd /apps/rpm
rm -rf mysql-5.7.31
rm -rf mysql-5.7.31.tar
rm -rf mysql-boost-5.7.31.tar.gz

chown -R apps:apps /apps
chmod -R 755 /apps

  1. 初始化数据库:(-–datadir目标目录下不能有数据文件)

su - apps

/apps/svr/mysql57/bin/mysqld --defaults-file=/apps/conf/mysql/mysql57_3306.cnf --initialize-insecure --user=apps #root 密码为空

  1. 启动MySQL:

nohup /apps/svr/mysql57/bin/mysqld_safe --defaults-file=/apps/conf/mysql/mysql57_3306.cnf --user=apps &

12.登录mysql
mysql

13.修改密码
ALTER USER 'root'@'localhost' IDENTIFIED BY 'root123';

14.重新登录
mysql -uroot -p

上一篇:微软忘记修复Mac Office2004/2008安全漏洞


下一篇:iOS 10.2.1 有偷拍漏洞!情人节防偷拍指南 | 宅客爱测试