RHEL7.2编译安装mysql5.7.13

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了RHEL7.2编译安装mysql5.7.13相关的知识,希望对你有一定的参考价值。

1、卸载系统自带的mysql或mariadb及boost

[[email protected] ~]# rpm -qa|grep mysql

[[email protected] ~]# rpm -qa|grep mariadb

mariadb-libs-5.5.44-2.el7.x86_64

[[email protected] ~]# rpm -e --nodeps mariadb-libs-5.5.44-2.el7.x86_64

[[email protected] ~]# rpm -qa|grep boost

boost-thread-1.53.0-25.el7.x86_64

boost-system-1.53.0-25.el7.x86_64

[[email protected] ~]# rpm -e --nodeps boost-thread-1.53.0-25.el7.x86_64

[[email protected] ~]# rpm -e --nodeps boost-system-1.53.0-25.el7.x86_64

[[email protected] ~]# rpm -qa| grep boost

[[email protected] ~]# 


2、查看是否存在mysql用户及组

[[email protected] boost]# cat /etc/group | grep mysql

[[email protected] boost]# cat /etc/passwd | grep mysql

[[email protected] boost]# 


3、创建mysql用户和组

[[email protected] boost]# groupadd mysql

[[email protected] boost]# useradd -r -g mysql mysql

[[email protected] boost]# 


4、创建mysql安装目录

[[email protected] boost]# mkdir /usr/local/mysql

[[email protected] boost]# mkdir /usr/local/mysql/data

[[email protected] boost]# 


5、安装编译软件

yum -y install make gcc-c++ cmake  libaio libaio-devel perl-Data-Dumper net-tools  ncurses-devel bison bison-devel gcc-c++ ncurses-devel cmake  perl gcc autoconf automake zlib libxml libgcrypt libtool 


6、安装lrzsz,使用lrzsz上传MySql压缩包

[[email protected] ~]# yum install lrzsz

[[email protected] ~]# rz

上传MySql压缩包


7、解压MySql数据包

[[email protected] ~]# tar zxvf mysql-boost-5.7.13.tar.gz 


8、cmake

cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data -DSYSCONFDIR=/etc -DMYSQL_UNIX_ADDR=/usr/local/mysql/data/mysql.sock -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1   -DMYSQL_TCP_PORT=3306 -DENABLED_LOCAL_INFILE=1  -DWITH_PARTITION_STORAGE_ENGINE=1 -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci  -DWITH_BOOST=/root/mysql-5.7.13/boost/ -DWITH_SYSTEMD=1


9、make

make -j 6 \\指定几个线程处理


10、make install    \\安装到指定目录


11、更改mysql目录权限

[[email protected] boost]# chown -R mysql:mysql /usr/local/mysql/


12、把mysql的执行路径加入PATH中 

[[email protected] mysql-5.7.13]# vi /etc/profile

export PATH=$PATH:/usr/local/mysql/bin            \\把此行加入到最后一行

[[email protected] mysql-5.7.13]# source /etc/profile


13、cp配置文件

# cp /usr/local/mysql/support-files/my-default.cnf   /etc/my.cnf 


14、修改/etc/my.cnf

basedir = /usr/local/mysql

datadir = /usr/local/mysql/data

port    = 3306

server_id = 1

socket = /usr/local/mysql/data/mysql.sock

log-error = /usr/local/mysql/data/mysql.err


15、配置并修改mysqld.service文件

[[email protected] mysql-5.7.13]# cp /usr/local/mysql/usr/lib/systemd/system/mysqld.service /usr/lib/systemd/system/

[[email protected] mysql-5.7.13]# 

vi /usr/lib/systemd/system/mysqld.service

PIDFile=/usr/local/mysql/data/mysqld.pid              \\修改成对应路径

--pid-file=/usr/local/mysql/data/mysqld.pid           \\修改成对应路径

[[email protected] ~]# systemctl daemon-reload


16、初始化数据库

[[email protected] ~]#/usr/local/mysql/bin/mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data


17、启动mysql进程

[[email protected] ~]# systemctl start mysqld


18、登录MySql数据库

[[email protected] system]# /usr/local/mysql/bin/mysql -u root


19、修改密码

ALTER USER ‘root‘@‘localhost‘ IDENTIFIED BY ‘[email protected]‘;


20、远程登录权限

GRANT ALL PRIVILEGES ON *.* TO [email protected]‘%‘ IDENTIFIED BY ‘[email protected]‘;

FLUSH PRIVILEGES;


21、配置mysql自启动

[[email protected] ~]# systemctl enable mysqld


22、为mysql开启防火墙 

firewall-cmd --permanent --zone=public --add-port=3306/tcp


本文出自 “高家大少的技术库” 博客,请务必保留此出处http://gaopengju.blog.51cto.com/12830710/1947596

以上是关于RHEL7.2编译安装mysql5.7.13的主要内容,如果未能解决你的问题,请参考以下文章

编译部署mysql5.7.13

MySQL5.7.13源码编译安装指南(转)

基于rhel7.2的Zabbix平台搭建和部署

linux安装MySQL5.7.13(二进制|源码)

基于centos6的mysql5.7.13主从部署

MySql之centos7.2安装mysql5.7.13