RHEL7.2编译安装mysql5.7.13

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

专注于为中小企业提供成都网站制作、网站建设服务,电脑端+手机端+微信端的三站合一,更高效的管理,为中小企业月湖免费做网站提供优质的服务。我们立足成都,凝聚了一批互联网行业人才,有力地推动了近1000家企业的稳健成长,帮助中小企业通过网站建设实现规模扩充和转变。

[root@node1 ~]# rpm -qa|grep mysql

[root@node1 ~]# rpm -qa|grep mariadb

mariadb-libs-5.5.44-2.el7.x86_64

[root@node1 ~]# rpm -e --nodeps mariadb-libs-5.5.44-2.el7.x86_64

[root@node1 ~]# rpm -qa|grep boost

boost-thread-1.53.0-25.el7.x86_64

boost-system-1.53.0-25.el7.x86_64

[root@node1 ~]# rpm -e --nodeps boost-thread-1.53.0-25.el7.x86_64

[root@node1 ~]# rpm -e --nodeps boost-system-1.53.0-25.el7.x86_64

[root@node1 ~]# rpm -qa| grep boost

[root@node1 ~]# 

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

[root@node1 boost]# cat /etc/group | grep mysql

[root@node1 boost]# cat /etc/passwd | grep mysql

[root@node1 boost]# 

3、创建mysql用户和组

[root@node1 boost]# groupadd mysql

[root@node1 boost]# useradd -r -g mysql mysql

[root@node1 boost]# 

4、创建mysql安装目录

[root@node1 boost]# mkdir /usr/local/mysql

[root@node1 boost]# mkdir /usr/local/mysql/data

[root@node1 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压缩包

[root@node1 ~]# yum install lrzsz

[root@node1 ~]# rz

上传MySql压缩包

7、解压MySql数据包

[root@node1 ~]# 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目录权限

[root@node1 boost]# chown -R mysql:mysql /usr/local/mysql/

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

[root@node1 mysql-5.7.13]# vi /etc/profile

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

[root@node1 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文件

[root@node1 mysql-5.7.13]# cp /usr/local/mysql/usr/lib/systemd/system/mysqld.service /usr/lib/systemd/system/

[root@node1 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           \\修改成对应路径

[root@node1 ~]# systemctl daemon-reload

16、初始化数据库

[root@node1 ~]#/usr/local/mysql/bin/mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data

17、启动mysql进程

[root@node1 ~]# systemctl start mysqld

18、登录MySql数据库

[root@node1 system]# /usr/local/mysql/bin/mysql -u root

19、修改密码

ALTER USER 'root'@'localhost' IDENTIFIED BY 'root@123';

20、远程登录权限

GRANT ALL PRIVILEGES ON *.* TO root@'%' IDENTIFIED BY 'root@123';

FLUSH PRIVILEGES;

21、配置mysql自启动

[root@node1 ~]# systemctl enable mysqld

22、为mysql开启防火墙 

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


标题名称:RHEL7.2编译安装mysql5.7.13
链接URL:http://ybzwz.com/article/jogsds.html