Liunx安装MySQL8(yum方式)

记录该文档的初衷是记录一下安装记录,因为以前总是安装的时候导出查,而且经常碰到这样那样的坑。所以打算从头开始重新安装一遍,整片文档基于MySQL官网

一、基于Yum安装MySQL8

1、添加Yum存储库

文档地址:
官网原文:

First, add the MySQL Yum repository to your system’s repository list. This is a one-time operation, which can be performed by installing an RPM provided by MySQL. Follow these steps:

  1. Go to the Download MySQL Yum Repository page (https://dev.mysql.com/downloads/repo/yum/) in the MySQL Developer Zone.
  2. Select and download the release package for your platform.
  3. Install the downloaded release package with the following command, replacing platform-and-version-specific-package-name with the name of the downloaded RPM package:

翻译过来:
1、首先,将MySQL Yum存储库添加到系统的存储库列表中。此操作为一次性操作,只需安装MySQL提供的RPM即可完成。遵循以下步骤:
a、去对应的Yum仓库下载对应的对应的资源地址为:https://dev.mysql.com/downloads/repo/yum/
(当然这里也可以直接从服务器上下载)
image.png
b、选择适合我们平台的发布包(这里我们以centos7为例)
c、使用如下命令安装,将platform-and-version-specific-package-name替换为下载的RPM包名称:

补充:在安装前最好删除系统自带的MariaDB
查询是否安装了MariaDB: rpm -qa | grep mariadb
image.png
删除命令:rpm -e --nodeps mariadb-libs-5.5.68-1.el7.x86_64
删除完成后再次查询:rpm -qa | grep mariadb

2、将下载好的rpm文件上传至服务器(本文以 /usr/local/soft)
image.png
3、安装 yum install mysql80-community-release-el7-6.noarch.rpm
image.png
4、更新yum库
yum makecache
image.png

2、安装MySQL

1、yum install mysql-community-server
(这里有个坑!!!)
image.png
2、检查rpm文件前面是否正确
rpm --checksig mysql80-community-release-el7-6.noarch.rpm
可以发现没有秘钥,那么我们导入秘钥
image.png
3、导入秘钥
rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
导入成功后再次检查秘钥
rpm --checksig mysql80-community-release-el7-6.noarch.rpm
image.png
4、安装MySQL
yum install mysql-community-server
image.png
5、启动MySQL,并设置为开机启
启动Mysql:systemctl start mysqld
image.png
开机自启动:systemctl enable mysqld

3、配置Mysql

在完成了MySQL的安装之后我们需要进行一定的配置才能使用。首先就是要修改密码
1、修改密码
mysql默认的日志文件位于 /var/log/mysqld.log
cat /var/log/mysqld.log
image.png
2、登陆MySQL并修改密码
mysql -uroot -p
image.png
ALTER USER ‘root’@‘localhost’ IDENTIFIED BY 密码;
至此Mysql的安装已经完成,如果在使用过程中发现客户端无法连接到mysql可能是防火墙的原因。希望对有所帮助
参考:
https://dev.mysql.com/doc/refman/8.0/en/linux-installation-yum-repo.html

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值