我是靠谱客的博主 时尚火,最近开发中收集的这篇文章主要介绍最新centos8 yum安装mysql8因centos8不在免费服务,需解决yum源不可访问问题(这个问题的原因是:centos8官方已经停止提供服务,相应的yum源也已经移到归档源),觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

centos8 yum安装mysql8

  • 因centos8不在免费服务,需解决yum源不可访问问题(这个问题的原因是:centos8官方已经停止提供服务,相应的yum源也已经移到归档源)
    • mysql安装
      • 导入

因centos8不在免费服务,需解决yum源不可访问问题(这个问题的原因是:centos8官方已经停止提供服务,相应的yum源也已经移到归档源)

  1. 备份原来文件
mv CentOS-Linux-BaseOS.repo CentOS-Linux-BaseOS.repo.bak
mv CentOS-Linux-AppStream.repo CentOS-Linux-AppStream.repo.bak

  1. 编辑文件CentOS-Linux-BaseOS.repo和CentOS-Linux-AppStream.repo
vim /etc/yum.repos.d/CentOS-Linux-BaseOS.repo

注释原来配置,复制下面替换

[BaseOS]
name=Qcloud centos OS - $basearch
baseurl=http://mirrors.cloud.tencent.com/centos/$releasever/BaseOS/$basearch/os/
enabled=1
gpgcheck=1
gpgkey=http://mirrors.cloud.tencent.com/centos/RPM-GPG-KEY-CentOS-Official

最终如下

# CentOS-Linux-BaseOS.repo
# 
# The #mirrorlist system uses the connecting IP address of the client and the
# update status of each mirror to pick current mirrors that are geographically
# close to the client.  You should use this for CentOS updates unless you are
# manually picking other mirrors.
#
# If the #mirrorlist does not work for you, you can try the commented out
# baseurl line instead.

#[baseos]
#name=CentOS Linux $releasever - BaseOS
#mirrorlist=http://#mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=BaseOS&infra=$infra
#baseurl=http://vault.centos.org/$contentdir/$releasever/BaseOS/$basearch/os/
#gpgcheck=1
#enabled=1
#gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial


[BaseOS]
name=Qcloud centos OS - $basearch
baseurl=http://mirrors.cloud.tencent.com/centos/$releasever/BaseOS/$basearch/os/
enabled=1
gpgcheck=1
gpgkey=http://mirrors.cloud.tencent.com/centos/RPM-GPG-KEY-CentOS-Official
vim CentOS-Linux-AppStream.repo

注释原来配置,复制下面替换

[AppStream]
name=Qcloud centos AppStream - $basearch
baseurl=http://mirrors.cloud.tencent.com/centos/$releasever/AppStream/$basearch/os/
enabled=0
gpgcheck=1
gpgkey=http://mirrors.cloud.tencent.com/centos/RPM-GPG-KEY-CentOS-Official

最终如下

# CentOS-Linux-AppStream.repo
# 
# The #mirrorlist system uses the connecting IP address of the client and the
# update status of each mirror to pick current mirrors that are geographically
# close to the client.  You should use this for CentOS updates unless you are
# manually picking other mirrors.
#
# If the #mirrorlist does not work for you, you can try the commented out
# baseurl line instead.

#[appstream]
#name=CentOS Linux $releasever - AppStream
#mirrorlist=http://#mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=AppStream&infra=$infra
#baseurl=http://vault.centos.org/$contentdir/$releasever/AppStream/$basearch/os/
#gpgcheck=1
#enabled=1
#gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial


[AppStream]
name=Qcloud centos AppStream - $basearch
baseurl=http://mirrors.cloud.tencent.com/centos/$releasever/AppStream/$basearch/os/
enabled=0
gpgcheck=1
gpgkey=http://mirrors.cloud.tencent.com/centos/RPM-GPG-KEY-CentOS-Official
  1. 刷新yum缓存
yum clean all && yum makecache

mysql安装

centos8上通过yum安装MySQL

  1. 检查系统是否已安装MySQL相关,如果有则全部清除干净
#列出MySQL相关的安装包
 rpm -qa | grep mysql
#依次删除安装包
yum remove mysql-community-libs-8.0.22-1.el8.x86_64
yum remove mysql-community-common-8.0.29-1.el8.x86_64
yum remove mysql-community-client-8.0.22-1.el8.x86_64
yum remove mysql-community-devel-8.0.22-1.el8.x86_64
yum remove mysql-community-client-plugins-8.0.22-1.el8.x86_64
yum remove mysql-community-icu-data-files-8.0.29-1.el8.x86_64
  1. centos8下安装MySQL8的yum源
#下载源(可自行到官网下载)
wget https://dev.mysql.com/get/mysql80-community-release-el8-3.noarch.rpm
#安装源
yum install mysql80-community-release-el8-3.noarch.rpm
# 安装完成mysql源,在执行一下yum源刷新(一开始我没执行,安装到最后一步报错,又重新卸载在安装,烦~)
yum makecache
  1. 关闭默认的MySQL(一定要执行,不然安装时会提示找不到包
yum module disable mysql
  1. 查看yum源支持的mysql版本
yum repolist all | grep mysql
[root@Canteen ~]# yum repolist all | grep mysql
mysql-cluster-8.0-community        MySQL Cluster 8.0 Community              禁用
mysql-cluster-8.0-community-source MySQL Cluster 8.0 Community - Source     禁用
mysql-connectors-community         MySQL Connectors Community               启用
mysql-connectors-community-source  MySQL Connectors Community - Source      禁用
mysql-tools-community              MySQL Tools Community                    启用
mysql-tools-community-source       MySQL Tools Community - Source           禁用
mysql-tools-preview                MySQL Tools Preview                      禁用
mysql-tools-preview-source         MySQL Tools Preview - Source             禁用
mysql80-community                  MySQL 8.0 Community Server               启用
mysql80-community-source           MySQL 8.0 Community Server - Source      禁用
  1. 可通编辑配置,以禁用或启用某个版本
vim /etc/yum.repos.d/mysql-community.repo
修改enable即可,0代表禁用,1代表启用
  1. MySql8安装(输入 y 下一步直到安装完成)
yum install mysql-community-server
  1. 启动MySQL服务,查看运行状态,开机自启
# 启动
systemctl start mysqld
# 状态
systemctl status mysqld
  1. 开机自启动设置
# 开机自启
systemctl enable mysqld
# 重新加载系统配置,使开机自启立马有效
systemctl daemon-reload
  1. 查看初始密码
grep 'temporary password' /var/log/mysqld.log
或者
vim /var/log/mysqld.log
# 如下
[root@Canteen ~]# grep 'temporary password' /var/log/mysqld.log
2022-07-07T04:16:56.991242Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: q(3jLLOkj*iQ
  1. 修改密码
ALTER USER 'root'@'localhost' IDENTIFIED BY '1qaz@WSX3edc';
flush privileges;
  1. 切换用户、查看用户数据库
mysql> use mysql;
mysql> select user,host from user;
+------------------+-----------+
| user             | host      |
+------------------+-----------+
| mysql.infoschema | localhost |
| mysql.session    | localhost |
| mysql.sys        | localhost |
| root             | localhost |
+------------------+-----------+
  1. mysql远程访问设置、查看用户数据库
mysql> update user set host='%' where user='root';
mysql> select user,host from user;
+------------------+-----------+
| user             | host      |
+------------------+-----------+
| root             | %         |
| mysql.infoschema | localhost |
| mysql.session    | localhost |
| mysql.sys        | localhost |
+------------------+-----------+
4 rows in set (0.00 sec)
  1. 密码加密规则还原成mysql_native_password
mysql> ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '1qaz@WSX3edc';
Query OK, 0 rows affected (0.01 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.02 sec)

导入

参考博客点击传送:打工人家

最后

以上就是时尚火为你收集整理的最新centos8 yum安装mysql8因centos8不在免费服务,需解决yum源不可访问问题(这个问题的原因是:centos8官方已经停止提供服务,相应的yum源也已经移到归档源)的全部内容,希望文章能够帮你解决最新centos8 yum安装mysql8因centos8不在免费服务,需解决yum源不可访问问题(这个问题的原因是:centos8官方已经停止提供服务,相应的yum源也已经移到归档源)所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(57)

评论列表共有 0 条评论

立即
投稿
返回
顶部