Centos7安装MySQL8

Centos7安装MySQL8

通过配置yum安装MySQL

yum源的配置是通过清华源配置的

https://mirrors.tuna.tsinghua.edu.cn/

环境介绍

操作系统:Centos7.8

MySQL版本:8.0.36-1

安装前准备

  1. 卸载MariaDB

    # 查看是否安装mariadb
    rpm -qa|grep mariadb
    
    # 卸载
    rpm -e --nodeps 文件名
    
    # 检查是否卸载干净
    rpm -qa|grep mariadb
    

    在这里插入图片描述

  2. 检查依赖

    # 查看是否安装libaio
    rpm -qa|grep libaio
    
    # 如果没有安装则执行
    yum -y install libaio //安装libaio 
    
    # 查看是否安装numactl
    rpm -qa|grep numactl
    
    # 如果没有安装则执行
    yum -y install numactl //安装numactl 	
    

    在这里插入图片描述

安装MySQL

创建yum源的过程:

https://mirrors.tuna.tsinghua.edu.cn/

在这里插入图片描述
在这里插入图片描述
即:

# 执行如下命令创建yum源文件
vim /etc/yum.repos.d/mysql-community.repo
# 将下面内容赋值到上面这个文档中
[mysql-connectors-community]
name=MySQL Connectors Community
baseurl=https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql-connectors-community-el7-$basearch/
enabled=1
gpgcheck=1
gpgkey=https://repo.mysql.com/RPM-GPG-KEY-mysql-2022

[mysql-tools-community]
name=MySQL Tools Community
baseurl=https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql-tools-community-el7-$basearch/
enabled=1
gpgcheck=1
gpgkey=https://repo.mysql.com/RPM-GPG-KEY-mysql-2022

[mysql-8.0-community]
name=MySQL 8.0 Community Server
baseurl=https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql-8.0-community-el7-$basearch/
enabled=1
gpgcheck=1
gpgkey=https://repo.mysql.com/RPM-GPG-KEY-mysql-2022

保存过后到/etc/yum.repos.d/ 下面会发下多了上面创建的mysql-community.repo yum源文件

使用yum安装MySQL

# 执行如下查看msyql版本 (--showduplicates 是查看对应版本)
yum search mysql-community-server --showduplicates
# 安装对应版本的mysql  (--nogpgcheck 是跳过gpg检查)
yum -y install mysql-community-server-8.0.36-1.el7.x86_64 --nogpgcheck

在这里插入图片描述

在这里插入图片描述

启动MySQL并修改初始密码

# 启动
systemctl start mysqld
# 查看mysql服务启动是否成功
systemctl status mysqld

在这里插入图片描述

#查看初始密码
grep 'temporary password' /var/log/mysqld.log

# 登录mysql,一定要注意:-p和'密码'之间是没有空格的
mysql -u root -p'x*qrf.jvo9mS'

#修改root初始密码
ALTER USER 'root'@'localhost' IDENTIFIED BY 'Root@123';

在这里插入图片描述

在这里插入图片描述

开放 root 账户远程登录

#重新登录
mysql -u root -p'Root@123'
# 1、进入数据库
use mysql;
# 2、修改user表
update user set host='%' where user='root';
# 重载授权表
FLUSH PRIVILEGES;
# 退出
exit

# 重启
systemctl restart mysqld

在这里插入图片描述

总结

至此安装完毕!

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值