centos7+ 安装mysql8

  • 关闭selinux
vi /etc/selinux/config
//修改为
SELINUX=disabled
  • 修改yum源为163
    具体参考:http://mirrors.163.com/.help/centos.html
// 备份  下载新的替换
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
yum clean all
yum makecache
  • 安装mysql8
yum localinstall https://repo.mysql.com//mysql80-community-release-el7-1.noarch.rpm
yum install mysql-community-server -y
  • 安装其他第三方依赖
yum install perl -y
yum install net-tools -y
  • 初始化mysql
mysqld --initialize
chmod -R 777 /var/lib/mysql/*
  • 查看初始密码
grep 'temporary password' /var/log/mysqld.log
2019-08-19T06:16:02.663494Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: 1wprTxF?fkY1
  • 启动并登录数据库
service mysqld start
mysql -uroot -p
  • 修改root账户密码
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '123123';
  • 允许root远程登录
use mysql;
update user set host = '%' where user ='root';
flush privileges;
//退出数据库, 修改 mysql 配置文件
vi /etc/my.cnf
[mysqld]
character-set-server=utf8
bind-address=0.0.0.0
  • 防火墙开启3306
firewall-cmd --zone=public --add-port=3306/tcp --permanent 
firewall-cmd --reload

你可能感兴趣的:(centos7+ 安装mysql8)