58 lines
984 B
Markdown
58 lines
984 B
Markdown
---
|
|
title: "CentOS7 yum 安装 Mysql5.7"
|
|
date: 2019-10-30T13:00:28+08:00
|
|
lastmod: 2019-10-30T13:00:28+08:00
|
|
tags: ["centos", "yum", "mysql"]
|
|
categories: ["database"]
|
|
---
|
|
|
|
# 环境
|
|
- CentOS 7.4 x86_64 最小安装
|
|
- MySQL 5.7.20
|
|
|
|
# 下载 mysql 源安装包
|
|
```bash
|
|
#repo 地址: https://repo.mysql.com/
|
|
cd /root/
|
|
curl -O https://repo.mysql.com/mysql57-community-release-el7.rpm
|
|
```
|
|
|
|
# 安装 mysql 源
|
|
```bash
|
|
rpm -ivh /root/mysql57-community-release-el7.rpm
|
|
```
|
|
|
|
# 更新 yum 缓存
|
|
```bash
|
|
yum clean all
|
|
yum makecache fast
|
|
```
|
|
|
|
# 安装 mysql
|
|
```bash
|
|
yum install mysql-community-server
|
|
```
|
|
|
|
# 启动 mysql
|
|
```bash
|
|
systemctl start mysqld
|
|
```
|
|
|
|
# 查找 mysql 默认密码
|
|
```bash
|
|
grep 'temporary password' /var/log/mysqld.log
|
|
mysql -uroot -p
|
|
# 输入查找到的密码
|
|
```
|
|
|
|
# 修改 mysql 本地密码
|
|
- 在 mysql 下修改
|
|
```sql
|
|
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'Pass-1234';
|
|
```
|
|
- 或者直接在终端修改
|
|
```bash
|
|
mysqladmin -uroot -p password 'Pass-1234'
|
|
```
|
|
|