centos7 安装 mysql 5.7

1.安装repo

yum localinstall https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm

2.安装 MySQL 5.7 Server

sudo yum install mysql-community-server --nogpgcheck

这一步可能会出现 ”异常1“ 中所示的现象,按照提供的方式解决后,再从新执行步骤2。

3.启动 MySQL Service

service mysqld start

4.获取临时密码

grep 'A temporary password' /var/log/mysqld.log |tail -1

输出

2022-06-09T16:09:21.898987Z 1 [Note] A temporary password is generated for root@localhost: qjdC0<O<GRC5

5.登录 mysql

mysql -h localhost -uroot -pqjdC0<O<GRC5;

登录后需要修改密码,不然没法进行下一步操作。

mysql>  ALTER USER 'root'@'localhost' IDENTIFIED  BY 'new-password';

6.查看数据库

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.00 sec)

到此,安装成功。

7.查看 mysql 版本

mysql -V
# 结果
mysql  Ver 14.14 Distrib 5.7.38, for Linux (x86_64) using  EditLine wrapper

异常1:GPG key 不正确

异常现象:

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

解决办法:

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

参考连接: https://tecadmin.net/install-mysql-5-7-centos-rhel/

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值