服务器环境:
centos7 x64
需要安装mysql5.7+
一、卸载CentOS7系统自带mariadb
# 查看系统自带的Mariadb
[root@CDH-141 ~]# rpm -qa|grep mariadb
mariadb-libs-5.5.44-2.el7.centos.x86_64
# 卸载系统自带的Mariadb
[root@CDH-141 ~]# rpm -e --nodeps mariadb-libs-5.5.44-2.el7.centos.x86_64
# 删除etc目录下的my.cnf
[root@CDH-141 ~]# rm /etc/my.cnf
二、检查mysql是否存在
# 检查mysql是否存在
[root@CDH-141 ~]# rpm -qa | grep mysql
[root@CDH-141 ~]#
三、查看用户和组是否存在
1)检查mysql组合用户是否存在
# 检查mysql组和用户是否存在,如无则创建
[root@CDH-141 ~]# cat /etc/group | grep mysql
[root@CDH-141 ~]# cat /etc/passwd | grep mysql
# 查询全部用户(只是做记录,没必要执行)
[root@CDH-141 ~]# cat /etc/passwd|grep -v nologin|grep -v halt|grep -v shutdown|awk -F ":" '{print $1 "|" $3 "1" $4}' | more
root|010
sync|510
flume|9921989
hdfs|9911988
zookeeper|9891986
llama|9881985
httpfs|9871984
mapred|9861983
sqoop|9851982
yarn|9841981
kms|9831980
hive|9821979
oozie|9801977
hbase|9781975
impala|9761973
hue|9741971
wlaqzc2018|100111001
[root@CDH-141 mysql]#
2)若不存在,则创建mysql组和用户
# 创建mysql用户组
[root@CDH-141 ~]# groupadd mysql
# 创建一个用户名为mysql的用户,并加入mysql用户组
[root@CDH-141 ~]# useradd -g mysql mysql
# 制定password 为111111
[root@CDH-141 ~]# passwd mysql
Changing password for user mysql.
New password:
BAD PASSWORD: The password is a palindrome
Retype new password:
passwd: all authentication tokens updated successfully.
四、下载mysql离线安装包tar文件
版本选择,可以选择一下两种方式:
1)使用Red Hat Enterprise LinuxSelect Version:5.7.25Select Operating System:Red Hat Enterprise Linux / Oracle LinuxSelect OS Version:Red Hat Enterprise Linux 7 / Oracle Linux 7 (x86, 64-bit)列表中下载:Compressed TAR Archive:(mysql-5.7.25-el7-x86_64.tar.gz)2)使用Linux - GenericSelect Version:5.7.25Select Operating System:Linux - GenericSelect OS Version:Linux - Generic (glibc 2.12) (x86, 64-bit)列表中下载:Compressed TAR Archive:(mysql-5.7.25-linux-glibc2.12-x86_64.tar.gz)【本文中使用的是这个版本】注意:上边两种方式找mysql离线安装包的方式都可以。
五、上传第四步下载的mysql TAR包
# 进入/usr/local/文件夹
[root@CDH-141 ~]# cd /usr/local/
# 上传mysql TAR包
[root@CDH-141 local]# rz
# 解压mysql-5.7.25-linux-glibc2.12-x86_64.tar.gz
[root@CDH-141 local