Centos7系统使用 yum 安装 MySQL5.7版本流程

1、下载并安装MySQL官方的 Yum Repository

wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm

2、安装mysql57-community-release-el7-10.noarch.rpm

yum -y install mysql57-community-release-el7-10.noarch.rpm

3、安装MySQL

yum -y install mysql-community-server

4、查看安装的MySQL信息

        4.1、查看是否成功

[root@centos7 ~]# mysql -V
mysql  Ver 14.14 Distrib 5.7.36, for Linux (x86_64) using  EditLine wrapper

        4.2、进入MySQL

        安装完成后,系统会在 /var/log/mysqld.log 默认创建 root 密码,我们先获取到密码。

        LnI!+M?fG8p6 这个便是 root的密码。

[root@centos7~]#  grep "password" /var/log/mysqld.log
[Note] A temporary password is generated for root@localhost: LnI!+M?fG8p6
[Note] Access denied for user 'root'@'localhost' (using password: NO)
[Note] Access denied for user 'root'@'localhost' (using password: NO)

        使用默认生成的密码登录MySQL后,不能进行,会提示如下的错误:

mysql> show databases;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql> 

        所以我们需要修改root的密码

ALTER USER 'root'@'localhost' IDENTIFIED BY 'new password';

        修改完密码,退出重新登录后查看可以操作,到此 MySQL 数据库的安装完成

卸载 Yum Repository 

yum -y remove mysql57-community-release-el7-10.noarch

备注内容:

使用yum -y install mysql-community-server安装mysql时候提示:
The GPG keys listed for the “MySQL 5.7 Community Server” repository are already installed but they are not correct for this package.
Check that the correct key URLs are configured for this repository.

Failing package is: mysql-community-libs-compat-5.7.37-1.el7.x86_64
GPG Keys are configured as: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
原因是Mysql的GPG升级了,需要重新获取

rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值