• CentOS 7安装MySQL 8.0教程


    在centos7中已经将mysql从yum应用列表中移除,并使用mariadb代替,所以直接通过yum install mysql-server安装时会提示没有可用软件包mysql-server。在centos7中安装mysql需要重新添加mysql的存储库。

    1. 下载MySQL提供的CentOS7的yum源

    方式一、官网下载 https://dev.mysql.com/downloads/repo/yum/

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


    方式二、CentOS命令下载

    [root@localhost ~]# curl https://repo.mysql.com//mysql80-community-release-el7-6.noarch.rpm > centos7.mysql.rpm
    
    
    • 1
    • 2

    在这里插入图片描述

    curl是CentOS系统自带的


    2. 安装yum源

    [root@localhost ~]# yum install centos7.mysql.rpm  
    
    • 1

    在这里插入图片描述

    3. 安装MySQL 8.0

    [root@localhost ~]# yum install mysql-community-server
    
    • 1

    4. 解决“安装mysql提示公钥尚未安装”

    在这里插入图片描述

    mysql-community-client-plugins-8.0.30-1.el7.x86_64.rpm 的公钥尚未安装

    运行如下命令

    [root@localhost ~]# rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
    
    
    • 1
    • 2

    再安装mysql [root@localhost ~]# yum install mysql-community-server

    在这里插入图片描述
    mysql安装成功~~~

    启动mysql [root@localhost ~]# systemctl start mysqld

    启动/停止/重启mysql:

    # 启动
    [root@localhost ~]# systemctl start mysqld 
    或
    [root@localhost ~]# service mysqld start  
    
    # 重启
    [root@localhost ~]# systemctl restart mysqld  
    或
    [root@localhost ~]# service mysqld restart
    
    # 停止
    [root@localhost ~]# systemctl stop mysqld  
    或
    [root@localhost ~]# service mysqld stop
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14

    设置开机启动mysql [root@localhost ~]# systemctl enable mysqld

    5. 初始化配置

    1)查看初始密码

    [root@localhost ~]# cat /var/log/mysqld.log | grep "password"
    
    • 1

    在这里插入图片描述

    2)安全初始化

    [root@localhost ~]# mysql_secure_installation
    
    • 1

    在这里插入图片描述

    在这里插入图片描述

    Change the password for root ? 更改root用户的密码?
    Do you wish to continue with the password provided?是否继续使用提供的密码?
    Remove anonymous users? 删除匿名用户?(建议选择Y 删除)
    Disallow root login remotely?禁止root远程登录?(默认不允许远程登录 )
    Remove test database and access to it?是否移除测试数据库(初学者建议先不移除N)
    Reload privilege tables now?是否现在重新加载特权表?(当我们更改了mysql用户相关的信息之后,建议重新加载Y)

    6. 基本使用

    1)登录mysql

    [root@localhost ~]# mysql -u root -p
    
    • 1

    在这里插入图片描述

    2)退出mysql

    mysql> exit
    
    • 1

    在这里插入图片描述

  • 相关阅读:
    抖音自动评论助手,其开发流程与需要的技术和代码分享
    【愚公系列】2022年11月 微信小程序-优购电商项目-商品支付页面
    阿里云Optane+QLC存储实践案例分享
    基于SpringBoot的冬奥会科普平台设计与实现-计算机毕业设计源码
    笔试强训48天——day12
    入门力扣自学笔记192 C++ (题目编号:1620)
    Qt raise()问题
    动态规划--区间dp
    python实现中缀表达式转后缀表达式
    dji uav建图导航系列()move_base
  • 原文地址:https://blog.csdn.net/weixin_43833100/article/details/126485188