安装新版mysql之前,需要将CentOS操作系统自带的数据库mariadb-lib卸载
[root@localhost home]$ rpm -qa|grep mariadb
mariadb-libs-5.5.56-2.el7.x86_64
[root@localhost home]$ yum remove? -y? mariadb-libs-5.5.56-2.el7.x86_64
1、在官网上[https://dev.mysql.com/downloads/mysql/)寻找到与操作系统相对应版本的mysql安装包。
这里下载的是:https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.20-1.el7.x86_64.rpm-bundle.tar
其他下载链接:[https://mirrors.tuna.tsinghua.edu.cn/mysql/)(下载速度会快点)
2、下载好通过MobaXterm 上传
cd /usr/local/
新建mysql目录
mkdir mysql
选择安装包,/opt/mysql上传到 目录下
解压安装包
tar -xvf mysql-8.0.20-1.el7.x86_64.rpm-bundle.tar
依次安装
common --> libs --> clients --> server
安装common
rpm -ivh mysql-community-common-8.0.20-1.el7.x86_64.rpm --nodeps --force
安装libs
rpm -ivh rpm -ivh mysql-community-libs-8.0.20-1.el7.x86_64.rpm --nodeps --force
rpm -ivh rpm -ivh mysql-community-libs-compat-8.0.20-1.el7.x86_64.rpm --nodeps --force
安装clients
rpm -ivh rpm -ivh mysql-community-client-8.0.20-1.el7.x86_64.rpm --nodeps --force
安装server
rpm -ivh rpm -ivh mysql-community-server-8.0.20-1.el7.x86_64.rpm --nodeps --force
查看 mysql 安装包
rpm -qa | grep mysql
mysqld --initialize;
chown mysql:mysql /var/lib/mysql -R;
systemctl start mysqld.service;
systemctl enable mysqld;