CentOS 7中安装MySQL - 根据官网文档

CentOS7中安装MySQL - 基于官网文档

前言

版本

CentOS7, 安装于windows的VMWare

MySQL5.7.13

时间: 2020年4月6日

个人的微小创举

这次安装经历很多困难, 一开始, 惯性思维+懒惰, 不愿意多费力费脑, 在中文网站找别人咀嚼过的解决方案, 但都被各种来回抄的答案坑惨.

后来没办法硬着头皮看MySQL官网的文档, 一开始还是用浏览器的全页翻译, 也很惨. 反而, 后来换成英文原文越看越深入, 越有感觉, 偶尔专业名词和记不清的词翻译一下, 居然解决了问题!

意义重大. 不止于这个问题的解决, 更重要的在于, 是首次完全通过官方英文文档解决的有难度的问题! 英文阅读, 并非高不可攀.

开始

准备工作

安装rz

可以通过xshell传输文件的工具

yum install lrzsz

安装依赖

yum -y install wget # 下载东西用的
yum -y install setup # 不过提示已经有最新版本了
yum -y install perl # 安装server要求的依赖
yum -y install net-tools # 安装server时候要求的依赖

卸载系统自带的mariadb

确认存在性

rpm -qa | grep mariadb

卸载

rpm -e mariadb-libs-5.5.64-1.el7.x86_64 --nodeps

--nodeps : 强制

下载安装

在linux的/目录下的自己的文件夹mine中(后来成功的那次没有用这个文件夹, 而是~目录)

下载

wget http://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.13-1.el7.x86_64.rpm-bundle.tar

但是, wget这次找的mirror太慢, 20k/s大概需要超过5h, 所以改用迅雷, 十多分钟搞定, 然后通过xshell传入虚拟机

解压

tar xvf mysql-5.7.13-1.el7.x86_64.rpm-bundle.tar 

安装

rpm -ivh [filename.rpm]

有依赖关系, 存在顺序性:

  1. rpm -ivh mysql-community-common-5.7.13-1.el7.x86_64.rpm
    
  2. rpm -ivh mysql-community-libs-5.7.13-1.el7.x86_64.rpm
    
  3. rpm -ivh mysql-community-libs-compat-5.7.13-1.el7.x86_64.rpm
    
  4. rpm -ivh mysql-community-client-5.7.13-1.el7.x86_64.rpm 
    
  5. rpm -ivh mysql-community-server-5.7.13-1.el7.x86_64.rpm
    

配置

启动:

需要手动启动

MySQL is not automatically started at the end of the installation process.

sudo service mysqld start

获取临时密码:

会得到一个临时密码temporary password 保存在/var/log/mysqld.log中, 找出它

A superuser account 'root'@'localhost' is created. A password for the superuser is set and stored in the error log file. To reveal it, use the following command for RHEL, Oracle Linux, CentOS, and Fedora systems:

grep 'temporary password' /var/log/mysqld.log

# 执行结果
2019-11-28T11:09:49.966857Z 1 [Note] A temporary password is generated for root@localhost: OUhb%s4)8ht;

**登录 **

mysql -uroot -p
# 临时密码, 注意复制要完整, 换行可能被忽略

修改密码

mysql> ALTER USER 'root'@'localhost' IDENTIFIED by 'aNewPassWordHere';

注意: 用root作密码会说不符合当前要求

如果安装过程中报错, 官方提示:

If something goes wrong during installation, you might find debug information in the error log file /var/log/mysqld.log.

WRITTEN BY ZhangCL

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值