mysql案例

举报
柳ioi 发表于 2022/07/10 23:48:43 2022/07/10
【摘要】 #  安装指定Mysql 版本## 需要的文件[RPM-GPG-KEY-mysql-2022](RPM-GPG-KEY-mysql-2022)  [mysql80-community-release-el7-6.noarch.rpm](mysql80-community-release-el7-6.noarch.rpm) ## 上传到centos服务器```bashscp D:\Resili...

#  安装指定Mysql 版本

## 需要的文件

[RPM-GPG-KEY-mysql-2022](RPM-GPG-KEY-mysql-2022)  

[mysql80-community-release-el7-6.noarch.rpm](mysql80-community-release-el7-6.noarch.rpm) 

## 上传到centos服务器

```bash
scp D:\ResilioSync\文档\MYSQL\mysql80-community-release-el7-6.noarch.rpm D:\ResilioSync\文档\MYSQL\RPM-GPG-KEY-mysql-2022 root@116.63.51.40:~
```

![image-20220705112707846](images/image-20220705112707846.png)

## 安装 rmp 和 GpG密钥

```bash
ls
yum install mysql80-community-release-el7-6.noarch.rpm -y
rpm --import RPM-GPG-KEY-mysql-2022
```

![image-20220705112914097](images/image-20220705112914097.png)

![image-20220705113003151](images/image-20220705113003151.png)

## 使用 yum-utils 管理扩展包

```bash
yum install yum-utils -y
```

![image-20220705113228853](images/image-20220705113228853.png)

## 修改MySQL默认安装版本

```bash
yum-config-manager --disable mysql80-community
yum-config-manager --enable mysql57-community
```

![image-20220705113535353](images/image-20220705113535353.png)

![image-20220705113557704](images/image-20220705113557704.png)

## 安装mysql 5.7

```bash
yum install mysql-community-server -y
```

![image-20220705113835308](images/image-20220705113835308.png)

# 启动&&配置

## 启动

```bash
systemctl start mysqld
systemctl enable mysqld
```

![image-20220705123750193](images/image-20220705123750193.png)

## 查看默认密码

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

![image-20220705123825689](images/image-20220705123825689.png)

## 修改默认密码

```bash
mysql -uroot -p

```

```sql
ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';
FLUSH PRIVILEGES;

```

![image-20220705124005174](images/image-20220705124005174.png)

## 创建远程连接用户

```sql
CREATE USER 'username'@'%' IDENTIFIED BY 'Password1!';
FLUSH PRIVILEGES;
```

![image-20220705124246630](images/image-20220705124246630.png)

## 用户授权所有数据库所有权限

```sql
 GRANT ALL ON *.* TO 'username'@'%';
 FLUSH PRIVILEGES;
```

![image-20220705124623982](images/image-20220705124623982.png)

## 修改用户密码

```sql
SET PASSWORD FOR 'username'@'%' = PASSWORD('newpassword');
FLUSH PRIVILEGES;
```

## 修改密码策略

### 查看当前策略

```sql
show VARIABLES like "%password%";
```

![image-20220705124845076](images/image-20220705124845076.png)

![img](images/webp.webp)

### 修改策略和密码长度

```sql
set global validate_password_policy=0;
set global validate_password_length=5;
FLUSH PRIVILEGES;
```

![image-20220705125122416](images/image-20220705125122416.png)

【版权声明】本文为华为云社区用户原创内容,转载时必须标注文章的来源(华为云社区)、文章链接、文章作者等基本信息, 否则作者和本社区有权追究责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。