Bootstrap

centos8安装mysql报错

root@hcss-ecs-2c66 ~]# sudo yum update
Repository powertools is listed more than once in the configuration
CentOS Linux 8 - PowerTools 90 B/s | 38 B 00:00
Error: Failed to download metadata for repo 'powertools': Cannot prepare internal mirrorlist: No URLs in mirrorlist


今天想下个mysql,配置下数据库,结果给我来这一出,太搞了。
一个个来

执行以下命令来查看所有存储库配置:

sudo grep -r 'powertools' /etc/yum.repos.d/

/etc/yum.repos.d/
/etc/yum.repos.d/CentOS-Linux-PowerTools.repo:[powertools]
/etc/yum.repos.d/CentOS-Linux-Sources.repo:[powertools-source]
/etc/yum.repos.d/CentOS-PowerTools.repo:[powertools]

然后发现果然powertools 仓库被多次配置了
禁用重复的 powertools 仓库配置:

sudo dnf config-manager --disable powertools

编辑 /etc/yum.repos.d/CentOS-Linux-PowerTools.repo:

sudo nano /etc/yum.repos.d/CentOS-Linux-PowerTools.repo

确保文件内容如下:

[powertools]
name=CentOS Linux $releasever - PowerTools
baseurl=http://mirror.centos.org/$contentdir/$releasever/powertools/$basearch/os/
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial

编辑 /etc/yum.repos.d/CentOS-PowerTools.repo:

sudo nano /etc/yum.repos.d/CentOS-PowerTools.repo

确保文件内容如下:

[powertools]
name=CentOS Linux $releasever - PowerTools
baseurl=http://mirror.centos.org/$contentdir/$releasever/powertools/$basearch/os/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial

编辑 /etc/yum.repos.d/CentOS-Linux-Sources.repo:

sudo nano /etc/yum.repos.d/CentOS-Linux-Sources.repo

确保文件内容如下:

[powertools-source]
name=CentOS Linux $releasever - PowerTools Source
baseurl=http://vault.centos.org/$contentdir/$releasever/powertools/Source/
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial

请注意,我们将只启用一个 powertools 配置块,其余的配置块均被禁用。

清理 DNF 缓存并更新系统:

sudo dnf clean all
sudo dnf update -y

验证 powertools 仓库是否正常:

sudo dnf repolist

添加 MySQL YUM 仓库:

sudo rpm -Uvh https://repo.mysql.com/mysql80-community-release-el8-1.noarch.rpm

安装 MySQL:

sudo yum install mysql-community-server -y

启动 MySQL 服务:

sudo systemctl start mysqld

设置 MySQL 开机自启动:

sudo systemctl enable mysqld

获取临时 root 密码:

sudo grep 'temporary password' /var/log/mysqld.log

运行 MySQL 安全安装向导:

sudo mysql_secure_installation

登录 MySQL:

mysql -u root -p

;