在 CentOS 1804 中 安装 MySQL 5.7.20 (或任意MySQL版本)

相关链接:

在 CentOS 1804 中 使用 yum 安装 MySQL 5.7 最新版

在 CentOS 1804 中 安装 MySQL 5.7.20 (或任意MySQL版本)

在 CentOS 1804 中 修改 MySQL 密码策略

在 CentOS 中 开启 MySQL 的 3306 端口

在不打开 MySQL 3306 端口的情况下,使用 Navicat 进项远程连接(使用22端口)

在 Ubuntu 中安装 MySQL5.7.20(任意版本)

在 Ubuntu 中安装 MySQL5.7.** 最新版

CentOS 6/7 安装 MySQL 8 最新版

CentOS 6/7 安装 MySQL 8.0.11 (或任意版)

MySQL 5.7 最新版 使用 yum 安装 MySQL NDB Cluster 7.5 最新版 集群

MySQL 集群 MySQL NDB Cluster 7.5.** 与 MySQL 5.7.** 对应版本说明

MySQL 集群 MySQL NDB Cluster 7.6.** 与 MySQL 5.7.** 对应版本说明

MySQL 5.7.20 (或指定版本) 与 MySQL NDB Cluster 7.6.4 (或指定版本) 集群

Windows 安装 MySQL 5.7.20 教程(及常见问题解决)

MySQL 5.7.20 (或任意版本) 的 Windows 版 安装程序 (msi) 下载


  1. 下载MySQL5.7.20(或任意版,笔者以5.7.20为例,截止笔者发稿,最新版为5.7.23)相关组件:
    下载网址:http://repo.mysql.com/yum/
    这里包含了MySQL的所有版本,如图所示:

    本人以5.7为例,打开mysql-5.7-community,如图所示:

    打开el(el是Red Hat,CentOS和CloudLinux的缩写),如图所示:

    选择7(代表CentOS 7等),如图所示:

    选择x86_x64,如图所示:

    在CentOS 1804 中安装MySQL 5.7.20需要的组件为(此顺序也是安装顺序):
    mysql-community-common-5.7.20-1.el7.x86_64.rpm
    mysql-community-libs-5.7.20-1.el7.x86_64.rpm
    mysql-community-client-5.7.20-1.el7.x86_64.rpm
    mysql-community-server-5.7.20-1.el7.x86_64.rpm
    mysql-community-libs-compat-5.7.20-1.el7.x86_64.rpm(选装)
    wget http://repo.mysql.com/yum/mysql-5.7-community/el/7/x86_64/mysql-community-common-5.7.20-1.el7.x86_64.rpm
    wget http://repo.mysql.com/yum/mysql-5.7-community/el/7/x86_64/mysql-community-libs-5.7.20-1.el7.x86_64.rpm
    wget http://repo.mysql.com/yum/mysql-5.7-community/el/7/x86_64/mysql-community-client-5.7.20-1.el7.x86_64.rpm
    wget http://repo.mysql.com/yum/mysql-5.7-community/el/7/x86_64/mysql-community-server-5.7.20-1.el7.x86_64.rpm
    wget http://repo.mysql.com/yum/mysql-5.7-community/el/7/x86_64/mysql-community-libs-compat-5.7.20-1.el7.x86_64.rpm
  2. 将下载好的组件上传到CentOS中,如图所示:

     
  3. 首先卸载maria:
    查看是否安装了maria:
    [root@CSDNBlogs ~]# rpm -qa | grep maria
    mariadb-libs-5.5.60-1.el7_5.x86_64
    
    卸载maria:
    [root@CSDNBlogs ~]# yum -y remove mariadb-libs-5.5.60-1.el7_5.x86_64
    
  4. 进入以上传文件目录:
    [root@CSDNBlogs ~]# cd /usr/java/doc/
    [root@CSDNBlogs doc]# ls
    mysql-community-client-5.7.20-1.el7.x86_64.rpm  mysql-community-libs-5.7.20-1.el7.x86_64.rpm
    mysql-community-common-5.7.20-1.el7.x86_64.rpm  mysql-community-server-5.7.20-1.el7.x86_64.rpm
    
  5. 安装mysql-community-common*:
    安装mysql-community-libs*:
    安装mysql-community-client*:
    安装mysql-community-server*:
    yum -y install mysql-community-common*
    yum -y install mysql-community-libs*
    yum -y install mysql-community-client*
    yum -y install mysql-community-server*
  6. 至此,已经安装完成,下面进行相关配置。
     
  7. 开启MySQL数据库:
    [root@CSDNBlogs doc]# systemctl start mysqld
    
  8. 开启MySQL的开机自启:
    [root@CSDNBlogs doc]# systemctl enable mysqld
  9. 重新载入:
    [root@CSDNBlogs doc]# systemctl daemon-reload
  10. 查看MySQL预设密码:
    使用命令(优先选择):
    [root@CSDNBlogs doc]# grep 'temporary password' /var/log/mysqld.log
    2018-09-21T02:47:01.590809Z 1 [Note] A temporary password is generated for root@localhost: 3:gd&v_2hw(H
    或者使用:
    [root@CSDNBlogs doc]# less /var/log/mysqld.log
    大约在第10行左右(每行开始为时间),显示如下:
    2018-09-21T02:47:01.590809Z 1 [Note] A temporary password is generated for root@localhost: 3:gd&v_2hw(H
    root@localhost后面就是预设密码。
  11. 登录MySQL数据库:
    [root@CSDNBlogs doc]# mysql -uroot -p
    Enter password: 
    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 5
    Server version: 5.7.20
    
    Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
    
    Oracle is a registered trademark of Oracle Corporation and/or its
    affiliates. Other names may be trademarks of their respective
    owners.
    
    Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
    
    mysql> 
    
    上面第5行显示为Server version: 5.7.20,是MySQL的版本(在这里吐槽一下,网上有很多方法查看MySQL安装版本,那些人想必没有仔细看过登录时的信息,说多了,言归正传)。
     
  12. 初次登录,修改数据库密码:
    推荐:
    mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';
    Query OK, 0 rows affected (0.00 sec)
    
    或:
    mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('MyNewPass4!');
    Query OK, 0 rows affected, 1 warning (0.00 sec)
    
    设置密码要符合规范(大小写,数字,特殊字符),不认设置不成功,如果想设置简单的密码,请阅读本文开头或结束的其他文章。
  13. 授权远程访问数据库:
    此方法不推荐,有其他更好的方式,请阅读本文开头或结束的其他文章。

    mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'Ass-Ubc+457';
    Query OK, 0 rows affected, 1 warning (0.00 sec)
    

    本文已完结。


相关链接:

在 CentOS 1804 中 使用 yum 安装 MySQL 5.7 最新版

在 CentOS 1804 中 安装 MySQL 5.7.20 (或任意MySQL版本)

在 CentOS 1804 中 修改 MySQL 密码策略

在 CentOS 中 开启 MySQL 的 3306 端口

在不打开 MySQL 3306 端口的情况下,使用 Navicat 进项远程连接(使用22端口)

在 Ubuntu 中安装 MySQL5.7.20(任意版本)

在 Ubuntu 中安装 MySQL5.7.** 最新版

CentOS 6/7 安装 MySQL 8 最新版

CentOS 6/7 安装 MySQL 8.0.11 (或任意版)

MySQL 5.7 最新版 使用 yum 安装 MySQL NDB Cluster 7.5 最新版 集群

MySQL 集群 MySQL NDB Cluster 7.5.** 与 MySQL 5.7.** 对应版本说明

MySQL 集群 MySQL NDB Cluster 7.6.** 与 MySQL 5.7.** 对应版本说明

MySQL 5.7.20 (或指定版本) 与 MySQL NDB Cluster 7.6.4 (或指定版本) 集群

Windows 安装 MySQL 5.7.20 教程(及常见问题解决)

MySQL 5.7.20 (或任意版本) 的 Windows 版 安装程序 (msi) 下载

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

徐晓伟

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值