CentOS7.9安装MySQL8.0

  • 关闭防火墙和selinux
systemctl stop firewalld
systemctl disable firewalld
setenforce 0
sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config
  • 获取并安装MySQL8.0源
wget http://repo.mysql.com/mysql80-community-release-el7.rpm
rpm -ivh mysql80-community-release-el7.rpm
安装rpm完成验证
  • 关闭mysql-community.repo中gpg校验
cd /etc/yum.repo
vi mysql-community.repo
gpgcheck=0
修改gpgcheck=0
  • 安装MySQL8.0
yum install mysql-server
  • 启动MySQL8.0设置开机自启动
systemctl start mysqld
systemctl status mysqld
systemctl enable mysqld
  • MySQL初始化设置
mysqld --initialize

#获取MySQL临时密码
grep 'temporary password' /var/log/mysqld.log

#修改MySQL密码<
alter user 'root'@'localhost' identified by 'P@ssw0rd';

use mysql;
#修改root账户权限
update user set host = '%' where user = 'root';

#刷新权限<br>flush privileges;

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注