MysqlRPM安装

下载RPM包

cd /usr/local/
mkdir mysql
//下载RPM Bundle
wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.22-1.el7.x86_64.rpm-bundle.tar
tar -xvf mysql-8.0.22-1.el7.x86_64.rpm-bundle.tar
//卸载Mariadb
rpm -qa | grep mariadb
//mariadb-libs-5.5.68-1.el7.x86_64
rpm -e mariadb-libs-5.5.68-1.el7.x86_64 --nodeps
//依次安装common libs client server
rpm -ivh mysql-community-common-8.0.22-1.el7.x86_64.rpm --nodeps --force
rpm -ivh mysql-community-libs-8.0.22-1.el7.x86_64.rpm --nodeps --force
rpm -ivh mysql-community-client-8.0.22-1.el7.x86_64.rpm --nodeps --force
rpm -ivh mysql-community-server-8.0.22-1.el7.x86_64.rpm --nodeps --force
rpm -qa | grep mysql
//mysql初始化
mysqld --initialize;
chown mysql:mysql /var/lib/mysql -R;
systemctl start mysqld.service;
systemctl enable mysqld;
//查看数据库密码
cat /var/log/mysqld.log | grep password
//改root密码
mysql -uroot -p
ALTER USER 'root'@'localhost' IDENTIFIED BY 'newpassword';
select host, user, authentication_string, plugin from user;
create user 'wuhaodong'@'%' identified by 'password';
grant all privileges on *.* to 'wuhaodong'@'%' with grant option;

Mysql编译安装

下载编译包
wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.22-el7-x86_64.tar
//官网https://dev.mysql.com/downloads/mysql/
tar -xvf mysql-8.0.22-el7-x86_64.tar
//得到三个文件
//mysql-test-8.0.22-el7-x86_64.tar.gz
//mysql-8.0.22-el7-x86_64.tar.gz
//mysql-router-8.0.22-el7-x86_64.tar.gz
yum install -y gcc gcc-c++ cmake openssl openssl-devel ncurses ncurses-devel libaio-devel
yum install epel-release -y
yum install cmake3 -y
//安装devtoolset包
yum install centos-release-scl
yum install devtoolset-4
//激活gcc版本,使其生效
scl enable devtoolset-4 bash

source /opt/rh/devtoolset-4/enable