哇塞,MySQL下载、静默安装、跨版本升级及卸载,保熟~

??????
哈喽!大家好,我是【IT邦德】,江湖人称jeames007,10年DBA工作经验
一位上进心十足的【大数据领域博主】!???
中国DBA联盟(ACDU)成员,目前从事DBA及程序编程
擅长主流数据Oracle、MySQL、PG 运维开发,备份恢复,安装迁移,性能优化、故障应急处理等。
✨ 如果有对【数据库】感兴趣的【小可爱】,欢迎关注【IT邦德】???
❤️❤️❤️感谢各位大可爱小可爱!❤️❤️❤️

前言

最近客户的数据要做升级,从5.7的版本升级到8.0,本文详细的概述了全过程


⛳️ 1.环境确认

✨ 1.1 操作系统

[[email protected] ~]# cat /etc/redhat-release
Red Hat Enterprise Linux release 8.1 (Ootpa)

✨ 1.2 防火墻

[[email protected] ~]# systemctl status firewalld

在这里插入图片描述

?? 关闭防火墙
systemctl stop firewalld
?? 取消开机自启动
[[email protected] ~]# systemctl disable firewalld
Removed /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.

✨ 1.3 selinux关闭

[[email protected] ~]# more /etc/sysconfig/selinux
修改/etc/selinux/config 文件
将SELINUX=enforcing改为SELINUX=disabled
??重启机器即可
[[email protected] ~]# sestatus
SELinux status: disabled
[[email protected] ~]# getenforce
Disabled

⛳️ 2.MySQL二进制包下载

官网:https://dev.mysql.com/downloads/mysql/

在这里插入图片描述
?? 安装包

mysql-5.7.30-linux-glibc2.12-x86_64.tar.gz
mysql-8.0.19-linux-glibc2.12-x86_64.tar.xz

⛳️ 3.安装MySQL 5.7

✨ 3.1 安装包解压

[[email protected] ~]# mkdir /soft
#二进制包解压
[[email protected] ~]# mkdir -p /usr/local/mysqlsoft
[[email protected] ~]# cd /soft/
tar -zxvf mysql-5.7.30-linux-glibc2.12-x86_64.tar.gz -C /usr/local/mysqlsoft
tar -Jxf mysql-8.0.19-linux-glibc2.12-x86_64.tar.xz -C /usr/local/mysqlsoft
#快捷方式创建
[[email protected] ~]# mkdir -p /usr/local/mysql57
[[email protected] ~]# mkdir -p /usr/local/mysql80

✨ 3.2 创建用户组

groupadd mysql
useradd -r -g mysql mysql
chown -R mysql:mysql /usr/local/mysqlsoft
[[email protected] soft]# passwd mysql

✨ 3.3.本地yum安装依赖

# 创建挂载路径
mkdir -p /mnt/cdrom

# 挂载系统镜像光盘到指定目录
mount -t iso9660 /dev/sr0 /mnt/cdrom

cd /etc/yum.repos.d

# 修改yum源配置文件
vi rhel8-local.repo
[localREPO]
name=localhost8
baseurl=file:///mnt/cdrom/BaseOS
enable=1
gpgcheck=0

[localREPO_APP]
name=localhost8_app
baseurl=file:///mnt/cdrom/AppStream
enable=1
gpgcheck=0

##安装依赖包
yum install libaio
yum -y install perl perl-devel
yum install libncurses*
yum -y install autoconf
yum -y install numactl.x86_64

✨ 3.4 初始化(5.7版本)

chown -R mysql.mysql /usr/local/mysql50
##静默安装
/usr/local/mysql57/mysql5730/bin/mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql57/mysql5730 --datadir=/usr/local/mysql57/mysql5730/data
##配环境变量
echo “export PATH=$PATH:/usr/local/mysql57/mysql5730/bin” >> /root/.bashrc
source /root/.bashrc

✨ 3.5 启动数据库

?? mysqld_safe &
在这里插入图片描述?? 新增用户及修改密码

mysql> select user,host,authentication_string from mysql.user;
##新增远程用户
mysql> grant all on . to [email protected]’%’ identified by ‘root’ with grant option;
mysql> flush privileges;
##修改本地密码
set password for [email protected]‘localhost’=password(‘root’);
mysql> flush privileges;

⛳️ 4.模拟数据,准备升级

mysql> show variables like ‘innodb_fast_shutdown%’;
±---------------------±------+
| Variable_name | Value |
±---------------------±------+
| innodb_fast_shutdown | 1 |
±---------------------±------+
1 row in set (0.01 sec)
内存数据全部落盘
mysql> set global innodb_fast_shutdown=0;
mysql> create database jeames;
Query OK, 1 row affected (0.00 sec)
#关闭Mysql
mysqladmin -uroot -proot shutdown

⛳️ 5.MySQL 5.0升级8.0

✨ 5.1 安装MySQL8.0.19

chown -R mysql.mysql /usr/local/mysql80
##静默安装MySQL
/usr/local/mysql80/mysql8019/bin/mysqld --initialize-insecure --user=mysql
–basedir=/usr/local/mysql80/mysql8019 --datadir=/usr/local/mysql80/mysql8019/data

✨ 5.2 修改mysql8配置文件

?? 指向5.7的数据文件及错误日志路径
vi /etc/my.cnf
[mysqld]
basedir=/usr/local/mysql80/mysql8019
datadir=/usr/local/mysql57/mysql5730/data
port=3306
log-error=/usr/local/mysql57/mysql5730/data/log.err
server_id=80193306
log-bin
default_authentication_plugin=mysql_native_password
character_set_server=utf8mb4

✨ 5.3 启动Mysq8019

cd /usr/local/mysql80/mysql8019/bin
mysqld_safe &
##输入密码为:5.7版本的密码(root)
在这里插入图片描述
echo “export PATH=$PATH:/usr/local/mysql80/mysql8019/bin” >> /root/.bashrc
source /root/.bashrc
???? 此处记得要删除原来的环境变量

⛳️ 6.MySQL卸载

yum remove -y mysql --nodeps
yum remove -y mysql-community-* --nodeps
rpm -qa|grep mysql|xargs rpm -e --nodeps
rpm -qa | grep mysql
rpm -e mysql-community-embedded-devel-5.7.30-1.el7.x86_64 --nodeps
rpm -e mysql-community-libs-5.7.30-1.el7.x86_64 --nodeps
rpm -e mysql-community-embedded-5.7.30-1.el7.x86_64 --nodeps
rpm -e mysql-community-embedded-compat-5.7.30-1.el7.x86_64 --nodeps
rpm -e mysql-community-common-5.7.30-1.el7.x86_64 --nodeps
rpm -e mysql-community-devel-5.7.30-1.el7.x86_64 --nodeps
rpm -e mysql-community-libs-compat-5.7.30-1.el7.x86_64 --nodeps
rm -rf /var/lib/mysql
rm -rf /var/log/mysqld.log
rm -rf /usr/lib/mysql
rm -rf /usr/include/mysql
rm -rf /etc/my.cnf
rm -rf /run/lock/subsys/mysql
find / -iname mysql

大家点赞、收藏、关注、评论啦 ??????微信公众号??????

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
THE END
分享
二维码
< <上一篇
下一篇>>